参数说明
通用选项
-formats 输出所有可用格式
-f fmt 指定格式(音频或视频格式)
-i filename 指定输入文件名,在linux下当然也能指定:0.0(屏幕录制)或摄像头
-y 覆盖已有文件
-t duration 记录时长为t
-fs limit_size 设置文件大小上限
-ss time_off 从指定的时间(s)开始, [-]hh:mm:ss[.xxx]的格式也支持
-itsoffset time_off 设置时间偏移(s),该选项影响所有后面的输入文件。该偏移被加到输入文件的时戳,定义一个正偏移意味着相应的流被延迟了 offset秒。 [-]hh:mm:ss[.xxx]的格式也支持
-title string 标题
-timestamp time 时间戳
-author string 作者
-copyright string 版权信息
-comment string 评论
-album string album名
-v verbose 与log相关的
-target type 设置目标文件类型("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)
-dframes number 设置要记录的帧数
视频选项:
-b 指定比特率(bits/s),似乎ffmpeg是自动VBR的,指定了就大概是平均比特率
-vb 指定视频比特率(bits/s)
-vframes number 设置转换多少桢(frame)的视频
-r rate 桢速率(fps)
-s size 分辨率
-aspect aspect 设置视频长宽比(4:3, 16:9 or 1.3333, 1.7777)
-croptop size 设置顶部切除尺寸(in pixels)
-cropbottom size 设置底部切除尺寸(in pixels)
-cropleft size 设置左切除尺寸 (in pixels)
-cropright size 设置右切除尺寸 (in pixels)
-padtop size 设置顶部补齐尺寸(in pixels)
-padbottom size 底补齐(in pixels)
-padleft size 左补齐(in pixels)
-padright size 右补齐(in pixels)
-padcolor color 补齐带颜色(000000-FFFFFF)
-vn 取消视频
-vcodec codec 强制使用codec编解码方式('copy' to copy stream)
-sameq 使用同样视频质量作为源(VBR)
-pass n 选择处理遍数(1或者2)。两遍编码非常有用。第一遍生成统计信息,第二遍生成精确的请求的码率
-passlogfile file 选择两遍的纪录文件名为file
-newvideo 在现在的视频流后面加入新的视频流
高级视频选项
-pix_fmt format set pixel format, 'list' as argument shows all the pixel formats supported
-intra 仅适用帧内编码
-qscale q 以<数值>质量为基础的VBR,取值0.01-255,约小质量越好
-loop_input 设置输入流的循环数(目前只对图像有效)
-loop_output 设置输出视频的循环数,比如输出gif时设为0表示无限循环
-g int 设置图像组大小
-cutoff int 设置截止频率
-qmin int 设定最小质量
-qmax int 设定最大质量
-qdiff int 量化标度间最大偏差 (VBR)
-bf int 使用frames B 帧,支持mpeg1,mpeg2,mpeg4
音频选项:
-ab 设置比特率(单位:bit/s,也许老版是kb/s)
-aframes number 设置转换多少桢(frame)的音频
-aq quality 设置音频质量 (指定编码)
-ar rate 设置音频采样率 (单位:Hz)
-ac channels 设置声道数
-an 取消音频
-acodec codec 指定音频编码('copy' to copy stream)
-vol volume 设置录制音量大小(默认为256)
-newaudio 在现在的音频流后面加入新的音频流
字幕选项:
-sn 取消字幕
-scodec codec 设置字幕编码('copy' to copy stream)
-newsubtitle 在当前字幕后新增
-slang code 设置字幕所用的ISO 639编码(3个字母)
Audio/Video 抓取选项:
-vc channel 设置视频捕获通道(只对DV1394)
-tvstd standard 设置电视标准 NTSC PAL(SECAM)
------------------
参数及例子(来自网络):
Anyways this article will guide you on how you can convert audio video formats using FFMPEG.
This articles in divided in various sections
Parameter Used
Command Line Syntax
Conversion Examples
Parameter Used:
Common Parameters
-i ‘filename’ Filename will be the Path of Source Filename
-y Overwrite the existing output file without prompting
-an disable audio
Video Related Parameters
-aspect ‘aspect ratio’ Set Aspect Ratio for the video (4:3, 16:9 or 1.3333, 1.7777)
-r ‘rate’ set frame rate in Hz for the video
-s ‘size’ set video resolution size (Width x Height)
-sameq use same video quality as source
Audio Related Parameters
-ar ‘rate’ set audio sampling rate (in Hz)
-acodec ‘codec’ force audio codec E.g. mp3
-vol ‘volume’ change audio volume (256=normal)
-ab ‘rate’ set audio bit rate (in bits/s)
Advanced Parameters
-map_meta_data output file:input file Copy the Metadata from Input File to Converted output file
Command Line Syntax
ffmpeg –i ‘input filename’ ‘output filename’
Syntax Example:
[root@linux /]# ffmpeg -i demo.mpg demo.flv
Here FFMPEG will convert demo.mpg file to demo.flv
Conversion Examples:
Video Examples:
Converting MOV to FLV using FFMPEG
ffmpeg -i movie1.mov movie1.flv
This will convert movie1.mov file to movie1.flv
Converting Mpeg to FLV using FFMPEG
ffmpeg -i movie1.mpeg movie1.flv
This will convert movie1.mpeg file to movie1.flv
Converting AVI to FLV using FFMPEG
ffmpeg -i movie1.avi -s 500×500 movie1.flv
This will convert movie1.avi file to movie1.flv and will resize the video resolution to 500×500
Converting 3GP to FLV using FFMPEG
ffmpeg -i movie1.3gp -sameq -an movie1.flv
This will convert movie1.3gp file to movie1.flv and will keep the original file settings and will disable the audio content
Converting MPEG to 3GP using FFMPEG
ffmpeg -i movie1.mpeg -ab 8.85k -acodec libamr_wb -ac 1 -ar 16000 -vcodec h263 -s qcif movie2.3gp
Audio Examples:
Converting aac to mp3 using FFMPEG with MetaData
ffmpeg -i audio1.aac -ar 22050 -ab 32 -map_meta_data audio1.mp3:audio1.aac audio1.mp3
This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz and will copy the meta data from .aac file to .mp3 file
Converting WMV to MP3 using FFMPEG
ffmpeg -i audio1.wmv audio1.mp3
This will convert audio1.wmv file to audio1.mp3
Converting WMV to FLV using FFMPEG
ffmpeg -i audio1.wmv audio1.flv
This will convert audio1.wmv file to audio1.flv, this will generate only audio content
Converting AMR to MP3 using FFMPEG
ffmpeg -i audio1.amr -ar 22050 audio1.mp3
This will convert audio1.amr file to audio1.mp3 having audio rate 22.05 Khz
Converting aac to mp3 using FFMPEG
ffmpeg -i audio1.aac -ar 22050 -ab 32 audio1.mp3
This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz
其他
iPod-iPhone 320 width
ffmpeg -i INPUT -s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -vpre ipod320 -acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
iPod-iPhone 320 width, without presset
ffmpeg -i INPUT -s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -coder 0 -bf 0 -flags2 -wpred-dct8x8 -level 13 -maxrate 768k -bufsize 3M-acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
DV Video To DV
ffmpeg -i input -target ntsc-dv -aspect 4:3 -y output.dv
From DV To Microsoft AVI DV
ffmpeg -i input.dv -vcodec copy -vtag dvsd -acodec pcm_s16le -f avi -aspect 4:3 -y output.avi
AAC to AC3 (Recomended use AviSynth for channel mapping)
ffmpeg -i intput.aac -vn -acodec ac3 -ac 6 -ar 48000 -ab 448k
AC3 to AAC (not working as expected)
ffmpeg -i input.ac3 -vn -r 30000/1001 -acodec libfaac -ac 6 -ar 48000 -ab 448k output.aac
pause
configuration: --enable-vdpau --enable-shared --disable-static
libavutil 50. 9. 0 / 50. 9. 0
libavcodec 52.55. 0 / 52.55. 0
libavformat 52.54. 0 / 52.54. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.10. 0 / 0.10. 0
我的测试
$ ffmpeg -i sample.aac -acodec vorbis -aq 60 sample.ogg
ffmpeg -i /tmp/radio/input.mp3 -acodec mp3 -ac 2 -ab 64
ffmpeg -i /tmp/radio/input.aac -acodec mp3 -ac 2 -ab 128
ffmpeg -i /tmp/radio/input.mp3 -acodec aac /tmp/radio/output.aac
ffmpeg -i D:\新建文件夹\sample.aac D:\新建文件夹\sample.mp3
./ffmpeg -i ./test.mp4 -acodec amr_nb -ar 8000 -ac 1 -ab 12 -y -vn out.amr
ffmpeg -i vdivx_amp3.avi -vcodec libx264 -b 1500000 -r 24 -async 1 -acodec libmp3lame -ar 44100 -ab 128000 -ac 2 output.avi