ffmpeg.exe下载

地址:http://pan.baidu.com/s/1o7YplUE

package com.exam.util;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.jeecgframework.core.common.model.common.UploadFile;
import org.jeecgframework.core.util.DateUtils;
import org.jeecgframework.core.util.FileUtils;
import org.jeecgframework.core.util.StringUtil;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.common.entity.DocumentBean;

public class UploadUtil {

	public static void main(String[] args) {
		VideoToVideo("E:/videoTest/tttttttt.mp4",
				"E:/videoTest/ffmpeg.exe",
				"E:/videoTest/tttttttt.flv");
	}
	/**
	 * 参数
	 * veido_path : 视频位置
	 * ffmpeg_path : 转换程序
	 * picPath : 图片位置
	 * */
	public static boolean VideoToPicture(String veido_path,String ffmpeg_path, String picPath) {  
		File file = new File(veido_path);  
		if (!file.exists()) {  
			System.err.println("路径[" + veido_path + "]对应的视频文件不存在!");  
			return false;  
		} 	
		List
   
   
    
     commands = new java.util.ArrayList
    
    
     
     ();  
		commands.add(ffmpeg_path);  
		commands.add("-i");  
		commands.add(veido_path);  
		commands.add("-y");  
		commands.add("-f");  
		commands.add("image2");  
		commands.add("-ss");  
		commands.add("20");//这个参数是设置截取视频多少秒时的画面  
		//commands.add("-t");  
		//commands.add("0.001");  
		commands.add("-s");  
		commands.add("700x525");  
		commands.add(picPath);  
	   try {  
			ProcessBuilder builder = new ProcessBuilder();  
			builder.command(commands);  
			builder.start();  
			System.out.println("截取成功");  
		   return true;  
	   	} catch (Exception e) {  
		   e.printStackTrace();  
		   return false;  
	    }  
	} 

	/**
	 * 将视频转为flv视频 
	 * */
	public static boolean VideoToVideo(String veidopath,String ffmpegpath, String codcFilePath) { 
		
		File file = new File(veidopath);  
		if (!file.exists()) {  
			System.err.println("路径[" + veidopath + "]对应的视频文件不存在!");  
			return false;  
		} 	
		// 创建一个List集合来保存转换视频文件为flv格式的命令
		List
     
     
      
       commands = new java.util.ArrayList
      
      
       
       ();  
        commands.add(ffmpegpath); // 添加转换工具路径
        commands.add("-i"); // 添加参数"-i",该参数指定要转换的文件
        commands.add(veidopath); // 添加要转换格式的视频文件的路径
        commands.add("-qscale");     //指定转换的质量
        commands.add("6");
        commands.add("-ab");        //设置音频码率
        commands.add("64");
        commands.add("-ac");        //设置声道数
        commands.add("2");
        commands.add("-ar");        //设置声音的采样频率
        commands.add("22050");
        commands.add("-r");        //设置帧频
        commands.add("24");
        commands.add("-y"); // 添加参数"-y",该参数指定将覆盖已存在的文件
        commands.add(codcFilePath);  
	   try {  
			ProcessBuilder builder = new ProcessBuilder();  
			builder.command(commands);
	        builder.redirectErrorStream(true);
	        builder.start();
			System.out.println("转码成功!");  
		   return true;  
	   	} catch (Exception e) {  
		   e.printStackTrace();  
		   return false;  
	    }  
	}
}

      
      
     
     
    
    
   
   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hi竹子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值