Ffmpeg+mencoder can almost complete any audio/video processing of the current Web-based podcast platform. 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 most visible features similar to YouTube can be implemented in the background in FFMPEG+MENCODER+FMS. Because the FMS has no practice, it is not described here.
This article has three parts:
1) Ffmpeg+mencoder Environment construction
2) Common operating instructions
3) Some of the experience of personal use
1.ffmpeg+mencoder Environment Construction
1) Introduction
The numerous codec protocols in the audio and video industry and the specialized formats defined by each company lead to the complexity of the current video audio files, and the simple ffmpeg supported formats do not entirely cover all kinds, at least swf,rmvb (RV4) The current version is not supported. At the same time wma9 seems to be able to support it. But there is no test. While mencoder can support formats such as RM,RMVB, the work of capturing a frame from the video can only be done by ffmpeg. Therefore, the use of ffmpeg+ MEncoder complete the current video compression conversion in all popular formats, set up video information, capture images in the video and other functions, while using other open source tools such as MediaInfo can get video metadata 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 it online, you can provide it.
FFmpeg Download: http://ffmpeg.mplayerhq.hu/ffmpeg-checkout-snapshot.tar.bz2 (SVN).
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/project/showfiles.php?group_id=290&package_id=309 or to xplore download lame.
Ogg Vorbis: This general Redhat comes with, does not need to download. You can go to see if/USR/LIB/LIBVORBIS.A is not in, if it is not available 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 ftp://ftp.videolan.org/under the search for the recent snapshot download, or SVN fetch, note if FFmpeg is when, x264 snapshot should also be when, Otherwise it is easy to error when compiling. ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
Xplore Download x264 's January 29 snapshot.
libdts:http://download.chinaunix.net/down.php?id=11568&resourceid=5785&site=1, Xplore download Libdts:
In addition to FFmpeg, the above package is unpacked after the download is complete, and the parameters of the compilation 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 their own automake to generate the compiled files after the unpacking is downloaded. Where the 1.25 version of FAAC needs to be removed from the last configure.in of the built-in Am_output file, and cancel the branch. Then follow the bootstrap inside the operation, nothing but aclocal-i. Autoheader;libtoolize--automake;automake-a--copy;autoconfig (or the previous replacement by Autoreconf-vif);. /configure--prefix=/usr--enable-shared;make;sudo make install;
Faad2 version 2.5 needs to modify the built-in configure.in file, otherwise 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;
Here are two of the modifications that have been made. Only make Clean;make;sudo make install, the tar package. faac1.25 download, faad2.5 download.
3GP support: When compiling ffmpeg to join--ENABLE-AMR_NB--ENABLE-AMR_WB, there will be prompt, download: http://www.3gpp.org/ftp/Specs/archive/26_series/ 26.204/26204-510.zip, unzip the source code file after the files are copied into the FFmpeg source code directory libavcodec/amrwb_float; then download: http://www.3gpp.org/ftp/ Specs/archive/26_series/26.104/26104-510.zip, extract the source code files after the files are copied to the FFmpeg unpacking directory libavcodec/amr_float, Then hand it over to ffmpeg and compile it.
You can also download these two packages here: amrwb_float download, amr_float download.
These codec are ready to compile ffmpeg and compile parameters as follows:
./configure--prefix=/usr/local--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
Make
(sudo make install)
Then you can try to do video conversion with FFmpeg.
3) mencoder article
First get the MPlayer package extremely mplayer official online codecs. If you like MPlayer, you can also download the GUI and font. About MPLAYER-1.0RC1 in 71.21 of/home/zhengyu/ Tools to find. If you need to download online, you can go to the official website: http://www.mplayerhq.hu/design7/dload.html. Download the RC1 address 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, including the 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, tar vxjf essential-20061022.tar.bz2;sudo mkdir-p/usr/lib/codecs;sudo cp-rf essential-20061022/*/usr/lib/ codecs; then unpack the 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 is a mplayer without a GUI that can play a variety of videos. But what we need is mencoder. At this point, the Ffmpeg+mencoder build is complete.
2. Common Operating Instructions
For FFmpeg, you can convert video/audio formats other than swf,rmvb,wmav9 to Flv/mp3, and you can intercept that frame picture at some time in these video files. These are actually part of a video podcast display. For MEncoder, supports a variety of common formats for video/audio conversion to 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 non-advanced parameters as follows:
Refer to 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 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 both 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 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 loops output in formats this 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 these are understood, and you have a programming base, you can participate in FFMPEG development. In fact, these stacked command 95% is generally not used. Here are some simple and common commands:
-fromats Display of available formats
-F FMT forced to use format FMT
-I. FileName input file
-Y Overwrite output file
-T duration set record time HH:MM:SS[.XXX] format is also supported (required)
-ss position search to the specified time [-]HH:MM:SS[.XXX] format also supports
-title String Setting Caption
-author String Setting author
-copyright string Setting Copyright
-comment String Setting Comment
-target type Sets the target file type (VCD,SVCD,DVD), all formatting options (bitrate, codec, and buffer size) are automatically set, just enter the following: Ffmpeg-i myfile.avi-target vcd/tmp/ Vcd.mpg
-HQ activating high-quality settings
-B bitrate Set bit rate, default 200kb/s
-R fps Set frame rate, default 25
-S size sets the frame size, formatted as WXH, by default 160x128. The following shorthand can also be used directly: Sqcif 128x96 qcif 176X144 CIF 252x288 4CIF 704X576
-aspect aspect set aspect ratio 4:3 16:9 or 1.3333 1.7777
-croptop/botton/left/right size Sets the top cut-out band sizes, pixel units
-padtop/botton/left/right size Sets the top-padded sizes, pixel units
-padcolor Color Set the completion bar colors (hex,6 16 binary number, red: Green: Blue arrangement, such as 000000 for Black)
-VN don't do video recording.
-BT tolerance Set video bitrate tolerance kbit/s
-maxrate bitrate set maximum video bitrate tolerance
-minrate bitreate set minimum video bitrate tolerance
-bufsize Size setting code rate control buffer sizes
-VCODEC codec enforces the use of codec codecs. If you use copy to indicate that the original codec data must be copied. (Very important)
-ab bitrate Set Audio bitrate
-ar freq Set Audio sample rate
-AC channels set Channel, default is 1
-an not enable audio recording
-ACODEC codec using codec codec
-VD Device settings for video capture devices, such as/dev/video0
-VC Channel set video capture channel DV1394 dedicated
-TVSTD standard SET TV standards NTSC PAL (SECAM)
-dv1394 setting DV1394 Capture
-av Device settings Audio devices such as/DEV/DSP
-map file:stream Setting the input stream mapping
-debug Printing specific Debug information
-benchmark add time to benchmark test
-hex dumping each input package
-bitexact only uses bit-accurate algorithms for codec testing
-ps size Sets the package sizes, in bits
-re with local frame frequency reading data, mainly used for analog capture devices
-loop the loop input stream. Works only with image streams for ffserver testing
Common ways to operate FFmpeg:
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. * *:* *:* * format, as for Ar,ab is the audio parameters, you can specify AR=22050,24000,44100 (PAL format), 48000 (NTSC), the latter two common, ab= 56 (depending on the codec of the audio protocol, if you want to listen to high quality, then more than 80). 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, can be obtained by viewing the professional codec documentation, if you have a detailed list of various codec documents, please provide a copy to me, greatly appreciated.)
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 adopt the corresponding codec parameters)
There are also many advanced parameters, such as-qmin,-qcale, please check the detailed documentation.
There are also-an and-VN parameters that extract pure video and audio from a multimedia file.
Alternatively, if you are using Shell batch processing, use the-y parameter override to generate the FLV.
2. Image capture: Ffmpeg-i infile.*-y (-ss second_offset)-T 0.001-s msize (-f image_fmt) outfile.jpg
Among them Second_offset ibid, msize with vsize, picture size. Image_fmt=image2 force use of jpg,image_fmt=gif, force the use of GIF format.
You can also use-vframes fn to designate a frame to intercept a picture, fn=1,2,3,...
2) mencoder article:
The role of mencoder is mainly in the aspect of video transcoding. After installing MPlayer, MEncoder also compiles. You can get the documentation for mencoder from man MEncoder.
MEncoder parameters more complex, but also is nothing more than audio processing video processing two aspects, you can see the network example: http://www.masoncn.com/post/144.html. Here is not a detailed list.
Common methods for MEncoder: 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 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
4.: MPlayer infile-ss start_time-noframedrop-nosound-vo jpeg-frames N
Where-OVC,-OAC and-of are required,-OVC is the specified video codec, specified OVC is usually taken with a codec after the OPT parameter,-OAC is the specified audio codec, A codec opt parameter is also followed. You can specify the details to determine the video audio quality and the conversion rate. For details, refer to the professional technical documentation.
3. Some personal experience
On the video podcast site, there are a few questions about the audio and video itself:
1) Some format audio and video files are not supported. Can't do the whole problem.
2) Upload the same content, but different format audio and video weight problem. There are different levels of solutions to describe this problem from the storage and application two aspects.
3) for some formats of audio and video files, it is possible to either be pure or pure video. such as the RM format. How to differentiate this file from the problem of easy application.
4) Audio and video retrieval, video description can not be done content way rather than user-defined keyword way.
5) The use and processing of audio and video similarity.
6) Download of audio and video files is available.
Using Ffmpeg+mencoder for the first problem can get an acceptable solution. The third problem is that you can install a front-end filter after uploading, differentiate between audio files and video files, and already have the appropriate open source tools and code to do these things. For the second question, First, the unified format, and then calculate the hash of the audio and video files, the storage part of the use of distributed CAS technology storage, application framework on the CAs. and the fourth question, the fifth question, needs to be studied in depth. The sixth question can be thought of as a peer-to-peer approach, but it's not too important.
For the use of shell in the Ffmpeg+mencoder+mediainfo environment processing video queue and capture video files, you can see this article.
Blog Source: http://huqilong.blog.51cto.com/53638/136985
Java Video Processing Ffmped+mencoder < eighth >