转载自: 视频技术论坛 中华视频网ffmpeg工程组 http://bbs.chinavideo.org/archiver/?fid-10.html
先从ffmpeg开始。
http://ffmpeg.sourceforge.net/上有说明,音视频的分离,转换,解码的完全解决方案。NAME
ffmpeg - FFmpeg video converter
SYNOPSIS
ffmpeg [[options][-i input_file]]... {[options] output_file}...
DESCRIPTION
If no input file is given, audio/video grabbing is done.
As a general rule, options are applied to the next specified file. For example, if you give the -b 64 option, it sets the video bitrate of the next file. Format option may be needed for raw input files.
By default, ffmpeg tries to convert as losslessly as possible: it uses the same audio and video parameter for the outputs as the one specified for the inputs.
OPTIONS
"Main options"
show license show help show available formats, codecs, protocols, ... force format input file name overwrite output files set the recording time in seconds. hh:mm:ss[.xxx] syntax is also supported. set the title set the author set the copyright set the comment activate high quality settings
"Video Options"
set the video bitrate in kbit/s (default = 200 kb/s) set frame rate (default = 25) set frame size. The format is WxH (default 160x128). The following abbreviations are recognized: 128x96 176x144 352x288 704x576 set aspect ratio (4:3, 16:9 or 1.3333, 1.7777) set top crop band size (in pixels) set bottom crop band size (in pixels) set left crop band size (in pixels) set right crop band size (in pixels) disable video recording set video bitrate tolerance (in kbit/s) set max video bitrate tolerance (in kbit/s) set min video bitrate tolerance (in kbit/s) set ratecontrol buffere size (in kbit) force video codec to codec. Use the copy special value to tell that the raw codec data must be copied as is. use same video quality as source (implies VBR) select the pass number (1 or 2). It is useful to do two pass encoding. The statistics of the video are recorded in the first pass and the video at the exact requested bit rate is generated in the second pass. select two pass log file name to file.
"Advanced Video Options"
set the group of picture size use only intra frames use fixed video quantiser scale (VBR) min video quantiser scale (VBR) max video quantiser scale (VBR) max difference between the quantiser scale (VBR) video quantiser scale blur (VBR) video quantiser scale compression (VBR) initial complexity for 1-pass encoding qp factor between p and b frames qp factor between p and i frames qp offset between p and b frames qp offset between p and i frames set rate control equation. Default is tex^qComp. rate control override for specific intervals set motion estimation method to method. Available methods are (from lower to best quality): Try just the (0, 0) vector. (default method) exhaustive search (slow and marginally better than epzs) set dct algorithm to algo. Available values are: FF_DCT_AUTO (default) FF_DCT_FASTINT FF_DCT_INT FF_DCT_MMX FF_DCT_MLIB FF_DCT_ALTIVEC set idct algorithm to algo. Available values are: FF_IDCT_AUTO (default) FF_IDCT_INT FF_IDCT_SIMPLE FF_IDCT_SIMPLEMMX FF_IDCT_LIBMPEG2MMX FF_IDCT_PS2 FF_IDCT_MLIB FF_IDCT_ARM FF_IDCT_ALTIVEC FF_IDCT_SH4 FF_IDCT_SIMPLEARM set error resilience to n. FF_ER_CAREFULL (default) FF_ER_COMPLIANT FF_ER_AGGRESSIVE FF_ER_VERY_AGGRESSIVE set error concealment to bit_mask. bit_mask is a bit mask of the following values: FF_EC_GUESS_MVS (default=enabled) FF_EC_DEBLOCK (default=enabled) use "frames" B frames (only MPEG-4) macroblock decision FF_MB_DECISION_SIMPLE: use mb_cmp (cannot change it yet in ffmpeg) FF_MB_DECISION_BITS: chooses the one which needs the fewest bits FF_MB_DECISION_RD: rate distoration use four motion vector by macroblock (only MPEG-4) use data partitioning (only MPEG-4) workaround not auto detected encoder bugs how strictly to follow the standarts enable Advanced intra coding (h263+) enable Unlimited Motion Vector (h263+) deinterlace pictures calculate PSNR of compressed frames dump video coding statistics to vstats_HHMMSS.log. insert video processing module. module contains the module name and its parameters separated by spaces.
"Audio Options"
set audio bitrate (in kbit/s) set the audio sampling freq (default = 44100 Hz) set the audio bitrate in kbit/s (default = 64) set the number of audio channels (default = 1) disable audio recording force audio codec to codec. Use the copy special value to tell that the raw codec data must be copied as is.
"Audio/Video grab options"
set video grab device (e.g. /dev/video0) set video grab channel (DV1394 only) set television standard (NTSC, PAL (SECAM)) set DV1394 grab set audio device (e.g. /dev/dsp)
"Advanced options"
set input stream mapping print specific debug info add timings for benchmarking dump each input packet only use bit exact algorithms (for codec testing) set packet size in bits read input at native frame rate. Mainly used to simulate a grab device. loop over the input stream. Currently it works only for image streams. This option is used for ffserver automatic testing.
"FFmpeg formula evaluator"
When evaluating a rate control string, FFmpeg uses an internal formula evaluator.
The following binary operators are available: +, -, *, /, ^.
The following unary operators are available: +, -, (...).
The following functions are available:
The following constants are available:
EXAMPLES
"Video and Audio grabbing"
FFmpeg can use a video4linux compatible video source and any Open Sound System audio source:
ffmpeg /tmp/out.mpg
Note that you must activate the right video source and channel before launching ffmpeg. You can use any TV viewer such as xawtv (<http://bytesex.org/xawtv/>) by Gerd Knorr which I find very good. You must also set correctly the audio recording levels with a standard mixer.
"Video and Audio file format conversion"
* ffmpeg can use any supported file format and protocol as input:
Examples:
* You can input from YUV files:
ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
It will use the files: /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V, /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the -s option if ffmpeg cannot guess it.
* You can input from a RAW YUV420P file:
ffmpeg -i /tmp/test.yuv /tmp/out.avi
The RAW YUV420P is a file containing RAW YUV planar, for each frame first come the Y plane followed by U and V planes, which are half vertical and horizontal resolution.
* You can output to a RAW YUV420P file:
ffmpeg -i mydivx.avi -o hugefile.yuv
* You can set several input files and output files:
ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
Convert the audio file a.wav and the raw yuv video file a.yuv to mpeg file a.mpg
* You can also do audio and video conversions at the same time:
ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.
* You can encode to several formats at the same time and define a mapping from input stream to output streams:
ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. "-map file:index" specify which input stream is used for each output stream, in the order of the definition of output streams.
* You can transcode decrypted VOBs
ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
This is a typical DVD ripper example, input from a VOB file, output to an AVI file with MPEG-4 video and MP3 audio, note that in this command we use B frames so the MPEG-4 stream is DivX5 compatible, GOP size is 300 that means an INTRA frame every 10 seconds for 29.97 fps input video. Also the audio stream is MP3 encoded so you need LAME support which is enabled using --enable-mp3lame when configuring. The mapping is particularly useful for DVD transcoding to get the desired audio language.
NOTE: to see the supported input formats, use ffmpeg -formats.
NAME
ffplay - FFplay media player
SYNOPSIS
ffplay [options] input_file
DESCRIPTION
FFplay is a very simple and portable media player using the FFmpeg libraries and the SDL library. It is mostly used as a test bench for the various APIs of FFmpeg.
OPTIONS
"Main options"
show help force displayed width force displayed height disable audio disable video disable graphical display force format
"Advanced options"
show the stream duration, the codec parameters, the current position in the stream, and the audio/video synchronisation drift. force RTP/TCP protocol usage instead of RTP/UDP. It is only meaningful if you are doing stream with the RTSP protocol. set the master clock to audio ( type=audio), video ( type=video) or external ( type=ext). Default is audio. The master clock is used to control audio-video synchronization. Most media players use audio as master clock, but in some cases (streaming or high quality broadcast) it is necessary to change that. This option is mainly used for debugging purposes.
NAME
ffsserver - FFserver video server
SYNOPSIS
ffserver [options]
DESCRIPTION
FFserver is a streaming server for both audio and video. It supports several live feeds, streaming from files and time shifting on live feeds (you can seek to positions in the past on each live feed, provided you specify a big enough feed storage in ffserver.conf).
This documentation covers only the streaming aspects of ffserver / ffmpeg. All questions about parameters for ffmpeg, codec questions, etc. are not covered here. Read ffmpeg-doc.html for more information.
OPTIONS
print the license print the help use configfile instead of /etc/ffserver.conf