This series of articles navigation
Quick Start for ffmpeg under Windows
FFmpeg parameter explanation
MEncoder and FFmpeg parameter detailed (Java processing video)
Java generated video thumbnails (ffmpeg)
Using FFmpeg to convert video files into FLV finishing
Java Video processing MEncoder
Java Video Processing Ffmped+mencoder
Ffmpeg+mencoder can almost complete the current Web-based podcast platform for any audio and video processing operations. If you need to add something, then the video online recording function, this can also be done with FFMPEG+FMS, As a result, some of the visible features similar to YouTube can be implemented in FFMPEG+MENCODER+FMS. Because the FMS has no practice, so here does not describe.
This article has three parts:
1) Ffmpeg+mencoder the environment to build
2) Common Operation instructions
3 personal experience of some use
1.ffmpeg+mencoder the environment to build
1) Introduction
The numerous codec protocols in the audio and video industry and the proprietary formats defined by each company lead to the complexity of the current video audio files, and the simple ffmpeg support format does not entirely include all kinds, at least swf,rmvb (RV4) The current version is not supported. At the same time, wma9 seems to support it. But there is no test. At the same time, mencoder can support RM,RMVB formats, but the task of capturing a screenshot from the video can only be done by ffmpeg. So you can use ffmpeg+ MEncoder completes the current all popular format video compression conversion, sets up the video information, intercepts the picture in the video and so on the function, at the same time, uses other open source tools such as MediaInfo to obtain the video the Meta data information.
2) FFmpeg article
First get the package: Ffmpeg,lame (Support mp3), OGG vorbis,x264 (H264 codec), XVID,3GP,LIBDTS,MPEG4 AAC. These packages are in the 71.21/home/zhengyu/ Tools can be found inside. If you need to download online, you can provide a download address.
FFmpeg website Download: http://ffmpeg.mplayerhq.hu/ffmpeg-checkout-snapshot.tar.bz2 (SVN).
If there is a problem with the website download, Xplore also provides the January 30 snapshot: Download FFmpeg.
Lame Download: The current version is 3.97,http://sourceforge.net/project/showfiles.php?group_id=290&package_id=309 or to xplore download lame.
Ogg Vorbis: This general redhat is self-contained and does not need to be downloaded. You can go and see if/USR/LIB/LIBVORBIS.A is not in, if not, yum install or apt-get install.
XviD download: http://downloads.xvid.org/downloads/xvidcore-1.1.0.tar.gz, Xplore download XviD.
x264 Download: This can go to the ftp://ftp.videolan.org/to find the latest snapshot download, or SVN fetch, note if FFmpeg is when, x264 should also be when the snapshot, Otherwise, it is easy to complain when compiling. ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
Xplore Downloads x264 's January 29 snapshot.
libdts:http://download.chinaunix.net/down.php?id=11568&resourceid=5785&site=1, Xplore download Libdts:
The above package, in addition to FFmpeg, after the download is complete unpack, compile parameters are./configure--prefix=/usr--enable-shared;make;sudo make install
MPEG4 aac/aad2:http://www.audiocoding.com/modules/mydownloads/visit.php?cid=1&lid=25&phpsessid= 8267ff75b7c18826fe75eb1c15690862,http://www.audiocoding.com/modules/mydownloads/visit.php?cid=1&lid=23 &phpsessid=8267ff75b7c18826fe75eb1c15690862.
FAAC and faad2 need to generate the compiled files themselves automake after downloading the package. FAAC version 1.25 needs to remove several continuation lines from the last configure.in of the built-in Am_output file. and cancel the branch. Then according to Bootstrap inside the operation, nothing but aclocal-i. Autoheader;libtoolize--automake;automake-a--copy;autoconfig (or preceded by autoreconf-vif substitution);. /configure--prefix=/usr--enable-shared;make;sudo make install;
Faad2 version 2.5 needs to modify the built-in configure.in file, or it will compile without libbmp. Find the following paragraph in configure.in: 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 into
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;
There are two of them that have been modified. The TAR package that requires only make Clean;make;sudo make install; faac1.25 downloads, faad2.5 downloads.
3GP support: When compiling ffmpeg to join--ENABLE-AMR_NB--ENABLE-AMR_WB, there will be a hint, download: http://www.3gpp.org/ftp/Specs/archive/26_series/ 26.204/26204-510.zip, extract the source code file after the files are copied to the FFmpeg source directory libavcodec/amrwb_float; then download: http://www.3gpp.org/ftp/ Specs/archive/26_series/26.104/26104-510.zip, extract the source code file after the files are copied to the FFmpeg unpack directory of Libavcodec/amr_float, Then give it to FFmpeg to do it.
You can also download these two packages here: Amrwb_float downloads, amr_float downloads.
After these codec are installed, you can compile the FFmpeg, and the compilation parameters are as follows:
./configure--prefix=/usr/local--ENABLE-GPL--enable-shared--enable-mp3lame--enable-amr_nb- Enable-amr_if2--enable-libogg--enable-vorbis--enable-xvid--enable-a52--enable-a52bin-- Enable-dts--enable-pp--enable-faad--ENABLE-FAAC--enable-x264--enable-pthreads-- Disable-ffplay
Make
(sudo make install)
Then you can try using FFmpeg to do a video conversion screenshot.
3) mencoder article
First get the MPlayer package extremely mplayer the official online codecs. If you like MPlayer, you can also download the GUI and font. About MPLAYER-1.0RC1 in 71.21/home/zhengyu/ Tools can be found. If you need to download online, you can go to the official website: http://www.mplayerhq.hu/design7/dload.html. Download RC1 address is as follows: Http://www1.mplayerhq.hu/MPlayer /releases/mplayer-1.0rc1.tar.bz2. Latest SVN version: http://www1.mplayerhq.hu/mplayer/releases/ mplayer-checkout-snapshot.tar.bz2. The official website also gives some codec, which have RM format codec:http://www1.mplayerhq.hu/mplayer/releases/ CODECS/ESSENTIAL-20061022.TAR.BZ2 (x86).
Xplore also offers downloads, mplayer1.0rc1 downloads, codec downloads.
After the download is complete, convert the tar vxjf essential-20061022.tar.bz2;sudo mkdir-p/usr/lib/codecs;sudo cp-rf essential-20061022/* Codecs and then unpack MPlayer and 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, and of course there's a mplayer with no GUI to play a variety of videos. But what we need is mencoder. So far, Ffmpeg+mencoder built.
2. Common Operation Instructions
For FFmpeg, you can convert a video/audio format other than swf,rmvb,wmav9 to a flv/mp3, and you can intercept the frame picture at a time in those video files. These are actually part of a video podcast show. For MEncoder, Supports various common formats for video/audio conversion into Flv/mp3. or convert to AVI.
1) ffmpeg article:
FFmpeg command-line arguments because too many, not listed here, can be viewed with ffpmeg-h. List the 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 frames to record
-R Rate Set frame rate (Hz value, fraction or abbreviation)
-S size set frame size (wxh or abbreviation)
-aspect aspect set aspect ratio (4:3, 16:9 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 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 dump each input packet
-hex when dumping packets, also dump the payload
-re read input at native frame rate
-loop_input Loop (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 all this is understood, and there is a programming base, you can go and participate in ffmpeg development. In fact, these piling up orders 95% is generally not used. Here are some simple common commands:
-fromats Displays the available formats
-F FMT forced to adopt format FMT
-I filename input file
-Y Overwrite output file
-T duration set record time HH:MM:SS[.XXX] format recording time also supported (screenshot required)
-ss position search to the specified time [-]HH:MM:SS[.XXX] format also supports
-title String Set Caption
-author String Sets the author
-copyright String Set Copyright
-comment String Set Comment
The-target type sets the target file type (VCD,SVCD,DVD), all formatting options (bit rate, codec, and buffer size) are automatically set, and you just need to enter the following: Ffmpeg-i myfile.avi-target vcd/tmp/ Vcd.mpg
-HQ Activate high quality settings
-B bitrate Set bit rate, default 200kb/s
-R fps Set frame frequency, default 25
-S size sets the frame size, the format is WxH, the default 160x128. The following abbreviations can also be used directly: Sqcif 128x96 qcif 176X144 CIF 252x288 4CIF 704x576
-aspect aspect Set horizontal longitudinal ratio 4:3 16:9 or 1.3333 1.7777
-croptop/botton/left/right size set top resection band size, pixel units
-padtop/botton/left/right size Sets the top-padded sizes, pixel units
-padcolor color sets the complement bar colors (hex,6 16, Red: Green: Blue arrangement, for example, 000000 for black)
-VN does not make video recordings
-BT tolerance Set video bitrate tolerance kbit/s
-maxrate bitrate set maximum video bitrate tolerance
-minrate bitreate set minimum video bitrate tolerance
-bufsize size Set bit rate control buffer size
-VCODEC codec enforces the use of codec codec. If you use copy to indicate that the original codec data must be copied. (Very important)
-ab bitrate set Audio code rate
-ar freq Set Audio sample rate
-AC channels set channel, defaults to 1
-an does not enable audio recording
-ACODEC codec using codec codec
-VD device set up video capture devices, such as/dev/video0
-VC Channel set video capture channel DV1394 dedicated
-TVSTD standard set TV standard NTSC PAL (SECAM)
-dv1394 Set DV1394 Capture
-AV device set up audio devices such as/DEV/DSP
-map File:stream Set Input stream mapping
-debug Print specific debugging information
-benchmark join time for benchmark test
-hex dumping every input package
-bitexact only use bit exact algorithm for codec test
-ps size to set the package sizes, in bits
-re read data in local frame frequency, mainly for analog capture devices
-loop the loop input stream. Works only on image streams for ffserver testing
Common methods for FFMPEG operations:
1. Convert to FLV file: Ffmpeg-i infile.*-y (-ss second_offset-ar ar-ab ab-r vr-b vb-s vsize) outfile.flv
Where Second_offset is a good second from the beginning. * *:* *:* * can be supported * format, as for Ar,ab is the audio parameters, you can specify the AR=22050,24000,44100 (PAL format), 48000 (NTSC), the latter two common, ab= 56 (depending on the codec of the audio and video protocol, if you want to listen to high quality, then 80 or more). Vr,vb,vsize is a video parameter that can be specified vr=15,25 (PAL), NTSC, vb=200,500,800,1500 (depending on the codec of the video protocol, You can get it by looking at the professional codec documentation, if you have a detailed list of various codec documents, please provide me with a copy.
There are also some parameters-acodec Ac-vcodec VC (AC specified audio Codec,ar and AB can be omitted, VC designated video CODEC,VR and VB can be omitted, automatically using the corresponding codec parameters)
There are many advanced parameters, such as-qmin,-qcale, please see the detailed documentation.
There are-an and-VN parameters, which extract pure video and audio from multimedia files respectively.
Alternatively, if you are using Shell batch processing, use the-y parameter overlay to generate FLV.
2. Capture Picture: Ffmpeg-i infile.*-y (-ss second_offset)-T 0.001-s msize (f image_fmt) outfile.jpg
Which Second_offset ibid, msize with vsize, picture size. Image_fmt=image2 enforces the use of jpg,image_fmt=gif, forcing the use of GIF format.
You can also use-vframes fn to specify a frame to intercept a picture, fn=1,2,3,...
2) mencoder article:
The function of mencoder is mainly in the aspect of video transcoding. After installing MPlayer, MEncoder is also compiled. Can man mencoder get mencoder documentation.
MEncoder's parameters are more complex, but nothing more than audio processing video processing two aspects, can refer to the network example: http://www.masoncn.com/post/144.html. There is no detailed enumeration here.
Common methods for mencoder operations: MEncoder infile.*-O outfile.* [-OVC target video format] [-OAC target audio format] [-of destination 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:vbit Rate=150:mbd=2:mv0:trell:v4mv:cbp:last_pred=3-srate 22050
MEncoder infile.rmvb-o outfile.flv-vf scale=-3:150-ofps 12-oac MP3LAME-OVC xvid-xvidencopts bitrate=112
2. Convert to AVI file: MEncoder infile.*-o outfile.avi-of avi-oac mp3lame-lameopts preset=64-ovc xvid-xvidencopts bitrate=600
3. Convert to WMV file (complex notation, where advanced parameters can be omitted): MEncoder infile.*-o outfile.wmv-of lavf-ofps 25-OAC mp3lame-lameopts 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
4. Screenshot: MPlayer infile-ss start_time-noframedrop-nosound-vo jpeg-frames N
Where-OVC,-OAC and-of are required,-OVC is the specified video codec, the OVC is usually followed by a codec opt parameter,-OAC is the specified audio codec, It will also be followed by a codec opt parameter. You can specify details to determine the video audio quality and conversion rate. Specific details can be reviewed in the professional technical documentation.
3. Some personal experience
On the video podcast site, there are several questions about the audio and video itself:
1 Some formats of audio and video files are not supported. It's not possible to do the whole thing.
2 Upload the same content, but the different format of audio and video row weight problem. Describing this problem from the storage and application two aspects will have different levels of solution.
3 for some formats of audio and video files, both may be pure audio, can also be pure video. such as RM format. The question of how to differentiate this file for easy application.
4 audio and video retrieval, video description can not be done content mode and not user-defined keyword way.
5 the use and processing of the similarity degree of audio and video.
6 Audio and video file download access.
Using Ffmpeg+mencoder for the first question can be an acceptable solution. The third problem is that you can install a front-end filter after uploading, distinguishing between audio files and video files, and already have the appropriate Open-source tools and code to do these things. For the second question, The first is a unified format, then compute the hash of audio and video files, in the storage part of the use of distributed CAS technology storage, the application of the architecture in the CAs. The fourth question, the fifth question, needs to be studied in depth. The sixth question can be considered peer-to-peer, but this is not too important.
For the use of shell in the Ffmpeg+mencoder+mediainfo environment for processing video queues and intercepting video files, you can refer to this article.
Blog Source: http://huqilong.blog.51cto.com/53638/136985