Java 上传视屏并生成缩略图

首先下载ffmpeg解压下载位置:https://download.csdn.net/download/weixin_39041673/10333948
 
建立一个bat文件
 
start
 
G:/ffmpeg/bin/ffmpeg.exe -i % 1 -ss 20 -vframes 1 -r 1 -ac 1 -ab 2 -s 160 * 120 -f  image2 % 2 
 
exit
  
 
G:/ffmpeg/bin/ffmpeg.exe ffmpeg的路径
 
% 1  % 2 和C语言有点相似是为传参数保留位置
 
20 要截取多少秒后的图片
 
打开MyEclipse,建立一个工程 ,以及一个java文件
 
package test;
 
import java.io.IOException;
 
public class Ffmpeg {
 
public static void main(String[] args) {
 
//视频文件  
 
         String videoRealPath = "F://瞬间.flv" ;  
 
         //截图的路径(输出路径)  
 
         String imageRealPath = "F://a.jpg" ;  
 
         try {  
 
             //调用批处理文件  
 
             Runtime.getRuntime().exec( "cmd /c start F://ffmpeg.bat " + videoRealPath + " " + imageRealPath);  
 
         } catch (IOException e) {  
 
             // TODO Auto-generated catch block  
 
             e.printStackTrace();  
 
         }
 
}
 
}
 
  

猜你喜欢

转载自blog.csdn.net/weixin_39041673/article/details/79854051