1、首先下载ffmpeg(附件即是)
2、将解压得到的ffmpeg.exe和pthreadGC2.dll文件解压到任何目录(当然也可以是WebRoot中的目录)
3、创建bat文件convertVideo.bat并添加以下内容:(参数说明见附录一)
Txt代码
%1\ffmpeg -i %2-y -ab56-ar22050-b500-r15-s320*240%3
exit%1\ffmpeg -i %2 -y -ab 56 -ar 22050 -b 500 -r 15 -s 320*240 %3
exit
******************
%1为ffmpeg存放目录
%2为需要转换的文件路径
%3为FLV文件输出目录
******************
同样需要注意的是bat文件存放的路径不能包含空格
也可以对视频进行截取缩略图哦:)
Txt代码
【转换文件格式的同时抓缩微图】
ffmpeg -i"test.avi"-y -f p_w_picpath2 -ss8-t0.001-s 350x240"test.jpg"
【对已有flv抓图】
ffmpeg -i"test.flv"-y -f p_w_picpath2 -ss8-t0.001-s 350x240"test.jpg"
****************
-ss后跟的时间单位为秒
****************【转换文件格式的同时抓缩微图】
ffmpeg -i "test.avi" -y -f p_w_picpath2 -ss 8 -t 0.001 -s 350x240 "test.jpg"
【对已有flv抓图】
ffmpeg -i "test.flv" -y -f p_w_picpath2 -ss 8 -t 0.001 -s 350x240 "test.jpg"
****************
-ss后跟的时间单位为秒
****************
4、创建类
Java代码
publicclassConvertVideo
{
privatestaticString INPUT_PATH;
privatestaticString OUTPUT_PATH;
privatestaticString PROJECT_PATH;
privatestaticHashMap fileType;
static
{
fileType =newHashMap();
fileType.put("avi","true");
fileType.put("mpg","true");
fileType.put("wmv","true");
fileType.put("3gp","true");
fileType