You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
8.2KB

  1. *************** FFMPEG soft VCR documentation *****************
  2. 0) Introduction
  3. ---------------
  4. FFmpeg is a very fast video and audio encoder. It can grab from
  5. files or from a live audio/video source.
  6. The command line interface is designed to be intuitive, in the sense
  7. that ffmpeg tries to figure out all the parameters, when
  8. possible. You have usually to give only the target bitrate you want.
  9. FFmpeg can also convert from any sample rate to any other, and
  10. resize video on the fly with a high quality polyphase filter.
  11. 1) Video and Audio grabbing
  12. ---------------------------
  13. * FFmpeg can use a video4linux compatible video source and any Open
  14. Sound System audio source:
  15. ffmpeg /tmp/out.mpg
  16. Note that you must activate the right video source and channel
  17. before launching ffmpeg. You can use any TV viewer such as xawtv by
  18. Gerd Knorr which I find very good. You must also set correctly the
  19. audio recording levels with a standard mixer.
  20. 2) Video and Audio file format convertion
  21. -----------------------------------------
  22. * ffmpeg can use any supported file format and protocol as input:
  23. Examples:
  24. * You can input from YUV files:
  25. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  26. It will use the files:
  27. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  28. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  29. The Y files use twice the resolution of the U and V files. They are
  30. raw files, without header. They can be generated by all decent video
  31. decoders. You must specify the size of the image with the '-s' option
  32. if ffmpeg cannot guess it.
  33. * You can input from a RAW YUV420P file:
  34. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  35. The RAW YUV420P is a file containing RAW YUV planar, for each frame first
  36. come the Y plane followed by U and V planes, which are half vertical and
  37. horizontal resolution.
  38. * You can output to a RAW YUV420P file:
  39. ffmpeg -i mydivx.avi -o hugefile.yuv
  40. * You can set several input files and output files:
  41. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  42. Convert the audio file a.wav and the raw yuv video file a.yuv
  43. to mpeg file a.mpg
  44. * You can also do audio and video convertions at the same time:
  45. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  46. Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.
  47. * You can encode to several formats at the same time and define a
  48. mapping from input stream to output streams:
  49. ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
  50. Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. '-map
  51. file:index' specify which input stream is used for each output
  52. stream, in the order of the definition of output streams.
  53. * You can transcode decrypted VOBs
  54. ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec
  55. mp3 -ab 128 snatch.avi
  56. This is a typicall DVD ripper example, input from a VOB file, output to
  57. an AVI file with MPEG-4 video and MP3 audio, note that in this command we
  58. use B frames so the MPEG-4 stream is DivX5 compatible, GOP size is 300
  59. that means an INTRA frame every 10 seconds for 29.97 fps input video.
  60. Also the audio stream is MP3 encoded so you need LAME support which is
  61. enabled using '--enable-mp3lame' when configuring.
  62. The mapping is particullary usefull for DVD transcoding to get the desired
  63. audio language.
  64. NOTE: to see the supported input formats, use 'ffmpeg -formats'.
  65. 2) Invocation
  66. -------------
  67. * The generic syntax is :
  68. ffmpeg [[options][-i input_file]]... {[options] output_file}...
  69. If no input file is given, audio/video grabbing is done.
  70. As a general rule, options are applied to the next specified
  71. file. For example, if you give the '-b 64' option, it sets the video
  72. bitrate of the next file. Format option may be needed for raw input
  73. files.
  74. By default, ffmpeg tries to convert as losslessly as possible: it
  75. uses the same audio and video parameter fors the outputs as the one
  76. specified for the inputs.
  77. * Main options are:
  78. -L show license
  79. -h show help
  80. -formats show available formats, codecs, protocols, ...
  81. -f fmt force format
  82. -i filename input file name
  83. -y overwrite output files
  84. -t duration set the recording time
  85. -title string set the title
  86. -author string set the author
  87. -copyright string set the copyright
  88. -comment string set the comment
  89. -b bitrate set video bitrate (in kbit/s)
  90. * Video Options are:
  91. -s size set frame size [160x128]
  92. -r fps set frame rate [25]
  93. -b bitrate set the video bitrate in kbit/s [200]
  94. -vn disable video recording [no]
  95. -bt tolerance set video bitrate tolerance (in kbit/s)
  96. -sameq use same video quality as source (implies VBR)
  97. -ab bitrate set audio bitrate (in kbit/s)
  98. * Audio Options are:
  99. -ar freq set the audio sampling freq [44100]
  100. -ab bitrate set the audio bitrate in kbit/s [64]
  101. -ac channels set the number of audio channels [1]
  102. -an disable audio recording [no]
  103. * Advanced options are:
  104. -map file:stream set input stream mapping
  105. -g gop_size set the group of picture size
  106. -intra use only intra frames
  107. -qscale q use fixed video quantiser scale (VBR)
  108. -qmin q min video quantiser scale (VBR)
  109. -qmax q max video quantiser scale (VBR)
  110. -qdiff q max difference between the quantiser scale (VBR)
  111. -qblur blur video quantiser scale blur (VBR)
  112. -qcomp compression video quantiser scale compression (VBR)
  113. -vd device set video device
  114. -vcodec codec force video codec
  115. -me method set motion estimation method
  116. -bf frames use 'frames' B frames (only MPEG-4)
  117. -hq activate high quality settings
  118. -4mv use four motion vector by macroblock (only MPEG-4)
  119. -ad device set audio device
  120. -acodec codec force audio codec
  121. -deinterlace deinterlace pictures
  122. -benchmark add timings for benchmarking
  123. -hex dump each input packet
  124. -psnr calculate PSNR of compressed frames
  125. -vstats dump video coding statistics to file
  126. The output file can be "-" to output to a pipe. This is only possible
  127. with mpeg1 and h263 formats.
  128. 3) Protocols
  129. ffmpeg handles also many protocols specified with the URL syntax.
  130. Use 'ffmpeg -formats' to have a list of the supported protocols.
  131. The protocol 'http:' is currently used only to communicate with
  132. ffserver (see the ffserver documentation). When ffmpeg will be a
  133. video player it will also be used for streaming :-)
  134. 4) File formats and codecs
  135. --------------------------
  136. Use 'ffmpeg -formats' to have a list of the supported output
  137. formats. Only some formats are handled as input, but it will improve
  138. in the next versions.
  139. 5) Tips
  140. -------
  141. - For streaming at very low bit rate application, use a low frame rate
  142. and a small gop size. This is especially true for real video where
  143. the Linux player does not seem to be very fast, so it can miss
  144. frames. An example is:
  145. ffmpeg -g 3 -r 3 -t 10 -b 50 -s qcif -f rv10 /tmp/b.rm
  146. - The parameter 'q' which is displayed while encoding is the current
  147. quantizer. The value of 1 indicates that a very good quality could
  148. be achieved. The value of 31 indicates the worst quality. If q=31
  149. too often, it means that the encoder cannot compress enough to meet
  150. your bit rate. You must either increase the bit rate, decrease the
  151. frame rate or decrease the frame size.
  152. - If your computer is not fast enough, you can speed up the
  153. compression at the expense of the compression ratio. You can use
  154. '-me zero' to speed up motion estimation, and '-intra' to disable
  155. completly motion estimation (you have only I frames, which means it
  156. is about as good as JPEG compression).
  157. - To have very low bitrates in audio, reduce the sampling frequency
  158. (down to 22050 kHz for mpeg audio, 22050 or 11025 for ac3).
  159. - To have a constant quality (but a variable bitrate), use the option
  160. '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
  161. quality).
  162. - When converting video files, you can use the '-sameq' option which
  163. uses in the encoder the same quality factor than in the decoder. It
  164. allows to be almost lossless in encoding.