ITeye博客

mmpeg转码

xuehanxin · 2013-01-09 11:43 · java基础 · linux · 编程语言 · Markdown

用例1:设置播放速率
ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
To set the video bitrate of the output file to 64kbit/s

用例2:强制文件播放帧速
To force the frame rate of the output file to 24 fps
用例3:amr转MP3
ffmpeg -i a.arm  -f mp3 -ar 11025  b.mp3

用例4:wav转mpg
ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg

用例4:
ffmpeg -i input.flac -id3v2_version 3 out.mp3

一段java的调用代码:

‘-f fmt (input/output)’

    public boolean armToMp3(String soundUrl){
       // ProcessBuilder builder = new ProcessBuilder();
    	String  armName = soundUrl.substring(soundUrl.lastIndexOf("/") + 1);
    	String path = soundUrl.replace(armName, "");
    	String name = armName.substring(0, armName.lastIndexOf(".") + 1); 
    //	String command = binDir + "ffmpeg -i " + soundUrl  +   "  -strict experimental -f wav -ar 11025 " + path + name + FORMAT;
    	String command = binDir + "ffmpeg -i " + soundUrl  +   "  -strict experimental -f mp3 -ar 11025 " + path + name + FORMAT;

    	log.debug("command...." + command);
    	//builder.command(command);
    	try{
	    Runtime.getRuntime().exec(command);
    	}catch(Exception e){
    		
    	}
    	return true;
    }

 linux安装ffmpeg需要安装转码库:第三方库是libmp3lame

安装方法见:

http://bbs.189works.com/thread-44808-1-1.html

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。