---
title: "mmpeg转码"
author: "xuehanxin"
date: "2013-01-09T11:43:02Z"
tags: []
categories: ["编程语言"]
slug: "mmpeg"
draft: false
lastmod: "2013-01-09T11:43:02Z"
id: 1766690
url: "https://blueyan.iteye.com/blog/1766690"
---

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