[Reprint] use of FFMPEG

Source: Internet
Author: User
ArticleDirectory
    • Use FFMPEG to convert Avi to 3GP command line parameters

Reproduced from: Video Technology Forum China video network FFMPEG Engineering Group http://bbs.chinavideo.org/archiver? Fid-10.html

Start with FFMPEG.

Http://ffmpeg.sourceforge.net/the following describes how to separate audio and video, Convert audio and video, and completely solve the code.
The most important one is the libavcodec library. It is used as a decoder by mplayer or xine. In addition, the mainstream player audio and video storm in China or mypc's backend ffdshow also uses the FFMPEG decoding library.

FFmpeg includes a set of software. FFmpeg is used to process media files. ffserver is an HTTP Streaming Media Server and ffplay is a simple SDL-based player. Two library files: libavcodec and libavformat.

As a media file processing software, FFmpeg is used as follows:
FFmpeg-I inputfile [Options] outputfile
The input and output files are usually multimedia files to be processed. It can be pure audio files, pure video files, or mixed files.
Most common formats can be used to "kill ". Such as common MPEG, Avi-encapsulated DivX, and XviD.
You can use FFMPEG-formats to view the list of supported formats or directly view the documentation.

In addition, because Linux regards a device as a file, the-I option can be followed by the device name. Such as DV, video card, optical drive, or other devices.
The output content is adjusted through options. List several major options
-Vcodec video stream encoding method
-B video stream bit rate (only 200 kb by default, which must be set manually. The specific value depends on codec selection)
-R video stream frames (generally, the PAL standard is 25, and the NTSC standard is 29)
-S Video resolution (resolution depends on codec and your needs. It usually takes a lot of CPU to change the resolution of a video stream. In addition, the specific format is "Number X number. The middle is the lowercase letter "X", which should be known if mplayer is used)
-T processing duration.
-Acodec audio stream encoding method
-AB audio stream bit rate (the default value is the same-source file bit rate, which also depends on codec)
-Ar audio stream sampling rate (44100 and 48000 are used in most cases, which correspond to the PAL and NTSC standards, respectively. Select as needed)

There are also some options that may be needed, such
-VN and-an respectively shield the video stream and shield the audio stream, and process the source file once to obtain the separated audio and video.
-Author-title: Set the author and title of a media file.
-F option is to force certain format
-Target type is converted to a DVD, VCD, or SVCD format)

In addition, there are some more advanced options, such as setting VBR, setting high quality, or setting the buff and max/min bit rates of VBR, like our own DVD capturing, DV is switched to VCD or DVD. It is not necessary to use movies downloaded from the Internet to VCD or DVD.
The specific usage is described in man. Simple and clear.

A little experience:
1: FFmpeg is not flattering about RM processing capabilities. It may be because I mainly use Binary packages for installation. For real media formats, only old-fashioned rv8 encoding formats can be processed. And the effect is not good.
2: format conversion is a very CPU-consuming task. Although FFmpeg is better than winavi, non-professional video processing software under tmpgenc is better. After all, we can put FFMPEG in the background when it is running.
3: FFmpeg is not omnipotent. Although it supports many formats, if you are not using the latest version of CVs, you may be depressed when encountering some weird media files.
4: FFmpeg is a command line operation. Which of the following experts can write a GUI front-end to bring many cainiao out of the sea. In addition, it cannot be processed in batches, but this can be solved using shell.

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 176x144x352x288 set aspect ratio (, or 704, 576) 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 1_ff_idct_ps2 ff_idct_mlib ff_idct_arm 1_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: Random (default = enabled) ff_ec_deblock (default = enabled) use "frames" B frames (only MPEG-4) macroblock demo-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 SNR 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 = 44100Hz) 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 ("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 22050Hz 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. 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 locking ing. the mapping is special 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 outcome 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

Use FFMPEG to convert Avi to 3GP command line parameters

FFmpeg-I test. Avi-y-B 20-s sqcif-R 10-AB 23.85-Ac 1-ar 8000 test.3gp
(The above parameters are released in the QQ group by the FFMPEG Project Group sunshine and Baiyun. Thank you for choosing them)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.