mmpeg轉碼

用例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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章