CLI派视频音频转码工具用法小结(ffmpeg)1 - 行者无疆 始于足下 - 行走,思考,在路上

CLI派视频音频转码工具用法小结(ffmpeg)1

xiaohanyu posted @ Fri, 23 Jul 2010 01:02:49 +0800 in Multimedia with tags FFMpeg linux , 4743 readers

1 ffmpeg 264编码支持

2 ffmpeg 参数选项简要说明

2.1 main options

  • -i filename: 指定输入文件
  • -y: Overwrite output files
  • -target: Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", … ). All the format options (bitrate, codecs, buffer sizes) are then set automatically. It is one of the most useful options of ffmpeg. It instructs ffmpeg to just "do what it takes" for the target file to be usable.

2.2 视频剪辑相关参数

  • -ss: 设定剪辑开始时间[支持[hh:mm:ss[.xxx]]格式
  • -t: 设定剪辑长度[支持[hh:mm:ss[.xxx]]格式
  • -fs: 设定文件大小限制

2.3 video options

  • -b bitrate: 设定比特率(默认为200kb/s)
  • -r fps: frame rate(默认为25)
  • -s size: set frame size
    • wxh(width x height) or
    • abbreviations(qcif(176x144), vga(640x480), wvga(852x480)
  • -aspect aspect: 设定aspect ratio(4:3, 16:9, 30:9, 1:3 or 1.333, 1.777 etc.)
  • -sameq: use same video quality as source (implies VBR).
  • -vcodec: codec: force video codec to codec. Use the copy special value to tell that the raw codec data must be copied as is.
  • -newvideo: add a new video stream to the current output stream.
  • -pass n 选择处理遍数(1或者2)。两遍编码非常有用。第一遍生成统计信息,第二遍生成精确的请求的码率
  • -map inputstreamid[:syncstreamid]: Set stream mapping from input streams to output streams.
  • -itsoffset offset Set the input time offset in seconds. "[-]hh:mm:ss[.xxx]" syntax is also supported. This option affects all the input files that follow it.

2.3.1 crop options(视频剪裁选项说明)

  • -crop x:y:width:height: Crop the input video to x:y:width:height.
  • -croptop
  • -cropbottom
  • -cropleft
  • -cropright

2.3.2 pad and filter options

  • -vf filter_graph
  • -vf pad=width:height:x:y:color(这个命令可以给裁剪后的视频增加上下两个pad,形成电影似的效果)

2.4 audio options

  • -ar freq: set the audio sampling frequency(default=44100Hz)
  • -ab bitrate: 设定比特率(默认为64K)
  • -aq q: set the audio quality
  • -ac channels: set the number of audio channels(default=1)
  • -acodec codec: force audio codec to codec. Use the copy special value to specify that the raw codec data must be copied as is.
  • -newaudio: add a new audio track to the output file. If you want to specify parameters, do so before -newaudio (-acodec, -ab, etc..).

2.5 subtitle options

  • -scodec codec: force subtitle codec ('copy' to copy stream).
  • -newsubtitle: add a new subtitle stream to the current output stream.

2.6 disable options

  • -an: disable audio recording.
  • -vn: disable video recording.
  • -sn: disable subtitle recording.

2.7 frames

  • -dframes number: set the number of data frames to record
  • -vframes number: set the number of video frames to record
  • -aframes number: set the number of audio frames to record

2.8 preset files

  • -vpre
  • -apre
  • -spre
  • -fpre

3 ffmpeg 用法示例(see http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs for more examples)

  • Basic Usage: ffmpeg [input options] -i [input file] [output options] [output file]
  • Normally the minimum one should specify in an ffmpeg command line would be something like: ffmpeg -i INFILE -acodec ACODEC -ab 96k -vcodec VCODEC -b 500k OUTFILE …replacing the capitalised values as appropriate. When using x264, we need to add some extra bits as the defaults are bad.
  • Getting infos from a video file: ffmpeg -i video.avi
  • Turn X images to a video sequence: ffmpeg -f image2 -i image%d.jpg video.mpg
  • Turn a video to X images: ffmpeg -i video.mpg image%d.jpg
  • Extracting sound from a video, and save it as Mp3: ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
  • Convert .avi video to .mpg: ffmpeg -i video_origine.avi video_finale.mpg
  • Convert .avi to animated gif(uncompressed): ffmpeg -i video_origine.avi -pix_fmt rgb24 gif_anime.gif
  • Mix a video with a sound file: ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
  • Compress .avi to VCD mpeg2 NTSC format: ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg
  • Multi-pass encoding with ffmpeg: ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2
  • Crop top 30 pixels and bottom 30 pixels to get a new video file: ffmpeg -i input_file.flv -croptop 30 -cropbottom 30 -target ntsc-dvd -aspect 16:9 output_file.mpg
  • Delaying the audio or the video: ffmpeg -i input1 -itsoffset 00:00:03.5 -i input2 ………..

4 ffmpeg learning resources

5 Related tools

5.1 transcode

5.2 mencode(from mplayer)

6 yamdi给视频增加关键帧

  • Yet Another MetaData Injector, see http://yamdi.sourceforge.net/
  • options:
    • -i: 输入文件
    • -o: 输出文件
    • -x: An XML file with the resulting metadata information.
    • -l: Adds the onLastSecond event(?).
  • other tools:
    • flvtool2: written by Ruby, slow, need more memory
    • flvmdi: not open source

7 ffmpegthumbnailer截取视频的thumbnail

  • ubuntu: sudo apt-get install ffmpegthumbnailer
  • options:
    • -i<s>: input file
    • -o<s>: output file
    • -s<n>: thumbnail size (default: 128)
    • -q<n>: image quality (0 = bad, 10 = best) (default: 8) (only for jpeg)
    • -c<s>: override image format (jpeg or png) (default: determined by filename)
    • -t<n|s>: time to seek to (percentage or absolute time hh:mm:ss) (default: 10%)
    • -a: ignore aspect ratio and generate square thumbnail
    • -f: create a movie strip overlay

8 Youku的一些探索

  • Youku网站上的大部分视频都是分段的,一般每段视频在5-10分钟之内
  • 目前Youku网上的视频格式大概有三种:
    • 高清mp4格式(h264编码)
    • 高清flv格式(h264编码)
    • 普通flv格式(应该是h263编码)

Author: Lox Freeman <xiaohanyu1988@gmail.com>

HTML generated by org-mode 6.21b in emacs 23


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee