java视频格式转换代码
http://blog.163.com/zzf_fly/blog/static/20958915820127217443816/
package com.gkzx.online.action;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import org.apache.struts2.ServletActionContext;
/*
* Title:FLV视频转换类
* @author 郑忠飞
* 2012-08-21
*/
public class Conver {
private Date dt;
private long begintime;
private String PATH;
private String filerealname; // 文件名 不包括扩展名
private String filename; // 包括扩展名
private String videofolder = null; // 别的格式视频的目录
private String flvfolder = null;// 转化为flv视频的存放目录
private final static String FFMPEGPATH = "/DownLoad/ffmpeg"; // ffmpeg.exe的目录
private final static String MENCODERPATH = "/DownLoad"; // ffmpeg.exe的目录
// private String videoRealPath = "D:/ffmpeg/flv/"; // 截图的视频目录;
// private String imageRealPath = "D:/ffmpeg/img/"; // 截图的存放目录
public Conver(String otherpath,String flvpath){
this.PATH = otherpath;//其他类型的视频文件文件夹
this.flvfolder = flvpath;//转换成为flv的格式之后视频存放的路径
}
/**
* 对视频格式进行转换
*
* @author 郑忠飞 2012-08-21
*/
public boolean beginConver() {
File fi = new File(PATH);
filename = fi.getName();
filerealname = filename.substring(0, filename.lastIndexOf("."))
.toLowerCase();
String videofolderTemp = PATH.substring(0,PATH.lastIndexOf("\\"));
videofolder = videofolderTemp.replace("flash", "other");
System.out.println("----接收到文件(" + PATH
+ ")需要转换-------------------------- \n");
if (!checkfile(PATH)) {
System.out.println(PATH + "文件不存在" + " ");
return false;
}
dt = new Date();
begintime = dt.getTime();
System.out.println("----开始转文件(" + PATH
+ ")-------------------------- \n");
if (process()) {
Date dt2 = new Date();
System.out.println("转换成功 \n");
long endtime = dt2.getTime();
long timecha = (endtime - begintime);
String totaltime = sumTime(timecha);
System.