FFmpeg + mencoder environment setup and video processing summary

Source: Internet
Author: User
Tags flv file automake
FFmpeg + mencoder can basically complete any audio/video processing operations on the current web-based podcast platform. if you still need to add something, it is the online video recording function, which can also be completed using FFMPEG + FMS, therefore, some visible functions similar to YouTube can be implemented in the background in FFMPEG + mencoder + FMS. this section does not describe because there is no practice in the FMS.
This document consists of three parts:
1) Build FFMPEG + mencoder Environment
2) Common Operations
3) personal experiences

1. Build FFMPEG + mencoder Environment

1) Overview
Many codec protocols and specialized formats defined by various companies in the audio and video industry make the current video and audio files complicated. The formats supported by FFMPEG alone do not fully include all types, at least SWF, the current version of rmvb (rv4) is not supported. at the same time, wma9 seems to be supported. but not tested. at the same time, mencoder supports RM, rmvb, and other formats, but obtaining a frame from a video can only be completed by FFMPEG. therefore, FFMPEG and mencoder can be used to compress and convert all popular formats of videos, set video information, and intercept images in videos. At the same time, other open-source tools such as mediainfo can be used to obtain video metadata.

2) FFMPEG
Obtain the software package FFMPEG, lame (MP3 supported), Ogg Vorbis, x264 (h264 codec), Xvid, 3GP, libdts, MPEG4 AAC. these packages can be found in 71.21/home/Zhengyu/tools. if you need to download it online, you can provide it.
FFmpeg official download: http://ffmpeg.mplayerhq.hu...
If there is a problem with the official website download, xplore also provides the January 30 snapshot: Download FFMPEG.

Lame download: the current version is 3.97, http://sourceforge.net/pro...
Or download lame from xplore.
Ogg Vorbis: This general RedHat comes with it and does not need to be downloaded. You can check whether/usr/lib/libvorbis. A is absent. If not, you can run Yum install or apt-Get install.
Xvid download: http://downloads.xvid.org/..., xplore download XviD.
Download x264: this can be done...
Xplore downloads the January 29 snapshot on x264.
Libdts: http://download.chinaunix..., xplore download libdts:
In addition to FFMPEG, the above software package is decompressed after download. The compiled parameters are./configure -- prefix =/usr -- enable-shared; Make; sudo make install.

MPEG4 AAc/aad2: http://www.audiocoding.com ..., http://www.audiocoding.com...
faac and faad2 require automake to generate the compilation file after downloading and uninstalling the package. in faac 1.25, the built-in configure is required. in file, remove the last several lines in am_output and cancel the branch. then follow the operations in Bootstrap, which is nothing more than aclocal-I .; autoheader; libtoolize -- automake; automake-A -- copy; AutoConfig (or replaced by autoreconf-vif );. /configure -- prefix =/usr -- enable-shared; Make; sudo make install;
In faad2 2.5, you must modify the built-in configure. in file, otherwise the compilation will fail if there is no libbmp. find configure. in the following section: reference if test x $ withbmp = xyes; then
ac_define ([have_bmp], 1, [user wants beep Media Player Plugin built])
am_conditional ([have_xmms], true)
am_conditional ([have_bmp], true)
fi

If test x $ withdrm = xyes; then
Change
If test x $ withbmp = xyes; then
Ac_define ([have_bmp], 1, [user wants beep Media Player Plugin built])
Am_conditional ([have_xmms], true)
Am_conditional ([have_bmp], true)
Else
Ac_msg_notice (no BMP build configured)
Am_conditional ([have_bmp], false)
Fi

If test x $ withdrm = xyes; then

Then autoreconf-VIF;./configure -- prefix =/usr -- enable-shared; Make; sudo make install;
Here we provide two modified tar packages: Make clean; Make; sudo make install;. faac1.25 and faad2.5.

3GP support: In the compilation of FFMPEG to add -- enable-amr_nb -- enable-amr_wb, there will be a prompt, download: http://www.3gpp.org/ftp/sp... decompressSource codeCopy all the files in the file to the FFMPEG source.CodeLibavcodec/amrwb_float under the Directory; then download: bytes.
You can also download these two packages here: amrwb_float and amr_float.

After the codec is installed, You can compile FFMPEG. The compilation parameters are as follows:
. /Configure -- prefix =/usr/local -- enable-GPL -- enable-shared -- enable-mp3lame -- enable-amr_nb -- enable-amr_wb -- enable-libogg -- enable-Vorbis -- enable-Xvid -- enable-amr_if2 -- enable-a52bin -- enable-faadbin -- enable-DTS -- enable-PP -- enable-faad -- enable-faac -- enable-x264 -- enable-pthreads -- disable-ffserver -- disable-ffplay
Make
(SUDO make install)
Then you can try to use FFMPEG for video conversion.
Of course, the above codec compilation is quite boring. you can ignore this. because the latest FFMPEG version supports more formats than before. therefore, you can only install lame, Xvid, and x264. the following is the result of the diff-W format supported by the two configurations: Reference 2C2
<Configuration: -- prefix =/usr -- enable-GPL -- enable-shared -- enable-mp3lame -- enable-amr_nb -- enable-amr_wb -- enable-amr_if2 -- enable-libogg -- enable-Vorbis -- enable-Xvid -- enable-a52 -- enable-a52bin -- enable- faadbin -- enable-DTS -- enable-PP -- enable-faad -- enable-faac -- enable-x264 -- enable-pthreads -- disable-ffserver -- disable-ffplay
---
> Configuration: -- prefix =/usr/local -- enable-mp3lame
6c6
<Built on Jan 30 2007 17:55:22, GCC: 4.1.1 20061011 (Red Hat 4.1.1-30)
---
> Built on Jan 30 2007 17:46:19, GCC: 4.1.1 20061011 (Red Hat 4.1.1-30)
40c40
<De gxf format
---
> D gxf format
72c72
<De Ogg Vorbis
---
> D Ogg
111d110
<DEA AAC
113c112
<DEA AC3
---
> EA AC3
132,133 d130
<DEA amr_nb
<DEA amr_wb
147d143
<D a DTS
164c160
<Dev DT h264
---
> D v dt h264
190d185
<D a mpeg4aac
275d269
<EV Xvid


3) mencoder
First, obtain the codecs package that comes with the mplayer official website. if you like mplayer, You can also download the GUI and font. about mplayer-1.0rc1 found in/home/Zhengyu/tools 71.21. if you need to download it online, you can go to the official website: workshop...
Xplore also provides download, mplayer1.0rc1 download, and Codec Download.

After the download is complete, run tar vxjf essential-20061022.tar.bz2; sudo mkdir-P/usr/lib/codecs; sudo CP-RF essential-20061022/*/usr/lib/codecs; then unpack mplayer, compile as follows:

. /Configure -- prefix =/usr/local -- enable-Gui -- enable-largefiles -- enable-GIF -- enable-PNG -- enable-JPEG -- language = zh_cn -- With-codecsdir =/usr /lib/codecs/
Make
(SUDO make install)

Then you can use mencoder. Of course, there is also a mplayer without a GUI that can play a variety of videos. However, we need mencoder. So far, FFMPEG + mencoder has been set up.

2. Common Operations
For FFMPEG, you can convert the video/audio formats except SWF, rmvb, and wmav9 to FLV/MP3, and intercept the frame image at a certain time in these video files. these are actually part of a video podcast. for mencoder, you can convert videos/audios in various common formats to FLV/MP3. or convert them to Avi.
1) FFMPEG:
The command line parameters of FFMPEG are too many and are not listed here. You can use ffpmeg-h to view the. list non-advanced parameters as follows:

Reference main options:
-L show license
-H Show Help
-Version show version
-Formats show available formats, codecs, protocols ,...
-F fmt force format
-I filename input file name
-Y overwrite output files
-T duration set the recording time
-Fs limit_size set the limit File Size
-SS time_off set the Start Time Offset
-Itsoffset time_off set the input ts offset
-Title string set the title
-Timestamp time set the timestamp
-Author string set the author
-Copyright string set the Copyright
-Comment string set the comment
-Album string set the album
-V verbose control amount of Logging
-Target type Specify target file type ("VCD", "SVCD", "DVD", "DV", "dv50", "Pal-VCD ", "NTSC-SVCD ",...)
-Dframes number set the number of data frames to record
-Scodec codec force subtitle codec ('copy' to copy Stream)
-Newsubtitle Add a new subtitle stream to the current output stream
-Slang Code set the ISO 639 language code (3 letters) of the current subtitle stream

Video options:
-Vframes number set the number of video frames to record
-R rate set frame rate (HZ value, fraction or abbreviation)
-S size set frame size (WXH or abbreviation)
-Aspect set aspect ratio (, or 1.3333, 1.7777)
-Croptop size set top crop band size (in pixels)
-Cropbottom size set bottom crop band size (in pixels)
-Cropleft size set left crop band size (in pixels)
-Cropright size set right crop band size (in pixels)
-Padtop size set top pad band size (in pixels)
-Padbottom size set bottom pad band size (in pixels)
-Padleft size set left pad band size (in pixels)
-Padright size set right pad band size (in pixels)
-Padcolor color set color of pad bands (hex 000000 thru ffffff)
-VN disable video
-Vcodec codec force video codec ('copy' to copy Stream)
-Sameq Use same video quality as source (implies VBR)
-Pass n select the pass number (1 or 2)
-Passlogfile file select two pass Log File Name
-Newvideo Add a new video stream to the current output stream

Subtitle options:
-Scodec codec force subtitle codec ('copy' to copy Stream)
-Newsubtitle Add a new subtitle stream to the current output stream
-Slang Code set the ISO 639 language code (3 letters) of the current subtitle stream

Audio/Video grab options:
-VD device set video Grab device
-VC channel set video grab channel (dv1394 only)
-Tvstd standard set television standard (NTSC, Pal (SECAM ))
-Ad device set audio device
-Grab format request grabbing using
-Gd device set Grab device

Advanced options:
-Map File: stream [: syncfile: syncstream] set input stream Mapping
-Map_meta_data OUTFILE: infile set meta data information of OUTFILE from infile
-Benchmark add timings for benchmarking
-Dump each input Packet
-Hex when dumping packets, also dump the payload
-Re read input at native Frame Rate
-Loop_input loop (current only works with images)
-Loop_output number of times to loop output in formats that support looping (0 loops forever)
-Threads count thread count
-Vsync video sync Method
-Async audio Sync method
-Vglobal video global header storage type
-Copyts copy timestamps
-Shortest finish encoding within shortest Input
-Dts_delta_threshold timestamp discontinuity Delta threshold
-PS size set packet size in bits
-Muxdelay seconds set the maximum Demux-Decode Delay
-Muxpreload seconds set the initial Demux-Decode Delay

if you understand all this and have a programming Foundation, you can participate in FFMPEG development. in fact, these stacked commands 95% are generally not used. here are some simple and Common commands:
-fromats display available formats
-f fmt forced to use FMT Format
-I filename input file
-y overwrites the output file
-T duration set the record time hh: MM: ss [. xxx] format record time is also supported (required)
-SS position to search for the specified time [-] hh: mm: ss [. the format of XXX] also supports
-title string setting title
-author string setting author
-Copyright string setting copyright
-Comment string setting comment
-target type: set the target file type (VCD, SVCD, DVD), all format options (bit rate, codec, and buffer size) are automatically set. You only need to enter the following: FFMPEG-I myfile. avi-target VCD/tmp/VCD. MPG
-activate high quality settings for HQ

-B bitrate: bit rate. The default value is kb/s.
-R fps: Specifies the frame rate. The default value is 25.
-S size: Specifies the frame size. The format is WXH. The default value is 160x128. You can also use the following shorthand: sqcif 128x96 qcif 176x144 CIF 252x288 4cif 704x576.
-Set aspect to or 1.3333 1.7777
-Croptop/botton/left/right size: Specifies the size of the top slice, in pixels.
-Padtop/botton/left/right size: Set the padding size on the top, in pixels.
-Padcolor color: Fill in the color (Hex, six hexadecimal numbers, Red: Green: blue, for example, 000000 represents black)
-VN does not record videos
-BT tolerance: sets the video bit rate tolerance kbit/s.
-Maxrate bitrate: sets the maximum video bit rate tolerance.
-Minrate bitreate: sets the minimum video bit rate tolerance.
-Bufsize size: sets the bit rate to control the buffer size.
-Vcodec codec enforces codec encoding/decoding. If copy is used, the original codec data must be copied. (important)

-AB bitrate: Set the audio bit rate.
-Ar freq: Set the audio Sampling Rate
-AC channels: Specifies the channel. The default value is 1.
-An does not enable audio recording
-Acodec codec uses codec encoding/Decoding

-VD device: sets a video capture device, such as/dev/video0.
-VC channel: Specifies the dedicated video capture channel dv1394.
-Tvstd standard: sets the TV standard NTSC pal (SECAM)
-Set dv1394 to capture dv1394
-AV device: Set audio devices such as/dev/DSP

-Map File: stream sets the input stream ing.
-Debug: Print specific debugging information
-Benchmark indicates the benchmark test time.
-Hex dumping each input package
-Bitexact only uses bit precisionAlgorithmUsed for Codec Testing
-PS size: Set the package size, in bits.
-Re reads data at a local frame rate, which is mainly used to simulate capturing devices.
-Loop input stream. Only works on image streams for ffserver Testing

Common Methods for FFMPEG operations:

1. convert to FLV file: FFMPEG-I infile. *-y (-SS second_offset-Ar-AB AB-r VR-B Vb-s vsize) OUTFILE. FLV
here, second_offset is how many seconds from the start. the **: ** format is supported. As for Ar, AB is the audio parameter. You can specify AR = 44100, 24000, 48000 (PAL), (NTSC ), the last two common types: AB = 56 (depending on the codec of the video/audio protocol. If you want to listen to high quality, 80 or more ). VR, VB, and vsize are video parameters. You can specify Vr = 15, 25 (PAL), 29 (NTSC), and VB = 200,500,800,150 0 (depending on the codec of the video protocol, you can refer to the professional codec instruction document. If you have a detailed codec instruction document, please provide it to me. Thank you very much .)
there are also some parameters-acodec ac-vcodec VC (AC can specify the audio codec, AR and AB, VC can specify the video codec, VR and VB can save, automatically use the corresponding codec parameters)
there are many advanced parameters, such as-qmin and-qcale. Please refer to the detailed documentation.
the-An and-VN parameters are also provided to extract pure video and audio from multimedia files.
In addition, if you use shell batch processing, use the-y parameter to overwrite the FLV.

2. screenshot: FFMPEG-I infile. *-y (-SS second_offset)-T 0.001-s msize (-F image_fmt) outfile.jpg
Here, second_offset is the same as above, and msize is the same as vsize. The image size. image_fmt = image2 is forced to use JPG, image_fmt = GIF, and forced to use GIF.
You can also use-vframes FN to specify a frame to intercept an image. fn =, 3 ,...

 
2) mencoder:
Mencoder is mainly used in video transcoding. After mplayer is installed, mencoder also generates a compilation. Man mencoder can get mencoder instructions.
Mencoder parameters are more complex, but they are nothing more than audio processing video. For more information, see the network example http://www.masoncn.com/pos...here.

Mencoder: mencoder infile. *-o outfile. * [-OVC target video format] [-OAC target audio format] [-of target file format]

1. convert to FLV file: mencoder infile. *-o outfile. FLV-of lavf-OAC mp3lame-lameopts ABR: Br = 56-OVC lavc-lavcopts vcodec = FLV: vbitrate = 150: mbd = 2: mv0: trell: v4mv: CBP: last_pred = 3-srate 22050
Mencoder infile. rmvb-o outfile. FLV-VF scale =--ofps 12-OAC mp3lame-OVC XviD-xvidencopts bitrate = 112

2. convert to an AVI file: mencoder infile. *-o outfile. Avi-of Avi-OAC mp3lame-lameopts preset = 64-OVC XviD-xvidencopts bitrate = 600

3. convert to a WMV file (complex writing method, where advanced parameters can be omitted): mencoder infile. *-o outfile. wmusic-of lavf-ofps 25-OAC mp3lame-lameopts CBR: preset = 128-OVC lavc-lavcopts vcodec = MPEG4: vbitrate = 768: mbd = 2: mv0: trell: v4mv: CBP: last_pred = 3-VF scale = 320: 240-srate 22050-SWS 9-subcp cp936-subpos 0-subalign 0-subfont-text-scale 3-lavfopts I _certify_that_my_video_strea

Among them,-OVC,-OAC and-of are required.-OVC specifies the video codec. After OVC is specified, it usually carries an opt parameter of the codec.-OAC specifies the audio codec, it will also include the OPT parameter of codec. you can specify details to determine the video audio quality and conversion rate. for details, refer to the professional technical documents.

3. Some personal experiences
On the video podcast website, there are several problems with the audio and video itself:
1) Some formats of audio and video files are not supported. They cannot be fully implemented.
2) the same content uploaded, but the audio and video deduplication in different formats. There are different levels of Solutions to describe the problem from the storage and application aspects.
3) for audio and video files in some formats, they may be either pure audio or pure video files, such as RM format. How to differentiate such files for ease of application.
4) for Audio/Video Retrieval, whether the video description can be implemented in the content mode rather than the keyword mode defined by the user.
5) use and Process audio and video similarity.
6) download and obtain audio and video files.

For the first problem, use FFMPEG + mencoder to obtain an acceptable solution. For the third problem, install a front-end filter after uploading.ProgramTo distinguish between audio files and video files, there are corresponding open-source tools and code to do these things. for the second problem, the first is to unify the format, and then calculate the hash of audio and video files. The storage part adopts the distributed CAS Technology for storage, and the application architecture is above the CAS. the fourth question is to be further studied. for the sixth question, we can consider the P2P approach, but this is not very important.
For how to use shell to process video queues and intercept video files in FFMPEG + mencoder + mediainfo, refer to this article.

reference Article : here to pay tribute to these article owners:
http://bbs.chinavideo.org /...
http://bbs.hljradio.com/ht...
http://blog.sina.com.cn/u...
http://blog.chinadaily.com...
http://ken.bokele.com /? Ch =...

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.