Use FFmpeg to convert media Video

Source: Internet
Author: User

Ffmpeg-i 1.wmv-c:v libx264-strict-2 1_wmv.mp4

Ffmpeg-i B.mp4-codec COPY-BSF H264_mp4toannexb a.ts


Ffmpeg-i 1.mp4-c:v LIBX264-CRF destination.flv


Ffmpeg-i hyb-wish.wav-acodec libmp3lame-ab 192k-ac 2 Hyb-wish.mp3
Ffmpeg-i hyb-wish.wav-acodec libfaac-ab 192k-ac 2 HYB-WISH.AAC
Ffmpeg-i hyb-wish.wav-acodec libamr_nb-ab 12.2k-ar 8000-ac 1 hyb-wish-nb.amr
Ffmpeg-i hyb-wish.wav-acodec libamr_wb-ab 23.85k-ar 16000-ac 1 hyb-wish-wb.amr

Reprinted from: http://www.cnblogs.com/super119/archive/2010/12/09/1901539.html

Now most of the so-called conversion software is based on FFmpeg, MEncoder also used is ffmpeg. FFmpeg is to do MPlayer's organization. So, why does a lot of software not convert some files and codec? Because FFmpeg doesn't support it. For example: Wmvv3 (WMV9) Encoding,ffmpeg now does not support, so basically now can see the conversion software is not supported, can only support WMVV1 (WMV7), Wmvv2 (WMV8) decode and encode.

Here are some steps and key points: 1. Compile ffmpeg yourself. Ubuntu Reposiroty in the FFmpeg function (mainly to see how to compile), such as the absence of Libmp3lame introduced, so, Ubuntu official repository ffmpeg is not encode MP3 (only encode MP2-MPEG 1 Audio Layer 2). Compiling the ffmpeg is simple, configure, make, and sudo make install is OK. Mainly configure, see what support to open, this time I do is:

./configure--prefix=/usr--ENABLE-GPL--enable-postproc--enable-nonfree--enable-pthreads--enable-x11grab-- ENABLE-LIBAMR-NB--enable-libamr-wb--ENABLE-LIBFAAC--enable-libfaad--enable-libmp3lame--enable-libx264-- Enable-libxvid--disable-armv5te--disable-armv6--disable-armv6t2--DISABLE-ARMVFP

Follow the command line above to install your own FAAC, Faad, Libmp3lame, Amrnb, AMRWB, x264 .... In particular, remember to install the dev version of these packages with a header file in the dev version of the package. It can also be seen here that ffmpeg is not every decoder/encoder, but also relies on many other projects. For example, x264, which is the organization of VLC player, is used for the encoder/decoder of H264.

2. Then the ffmpeg is used. can be very convenient to convert media files, such as: Ffmpeg-i hyb-wish.wav-acodec libmp3lame-ab 192k-ac 2 hyb-wish.mp3ffmpeg-i hyb-wish.wav-acodec LIBF Aac-ab 192k-ac 2 hyb-wish.aacffmpeg-i hyb-wish.wav-acodec libamr_nb-ab 12.2k-ar 8000-ac 1 hyb-wish-nb.amrffmpeg-i Hyb-wish.wav-acodec libamr_wb-ab 23.85k-ar 16000-ac 1 hyb-wish-wb.amr

See FFmpeg manual can know the meaning of these parameters, very simple:-i--input file; -acodec--Specifies the audio codec, with the Ffmpeg-formats command to see all the file formats and Codec;-ab supported by the currently compiled FFmpeg-bitrate, with a k behind the main number, otherwise invalid;-ac Specify the channel number;-ar Specify the sample rate, note that AMRNB is 8000,AMRWB 16000, the average is 44100/48000. The last parameter is the name of the output file, FFmpeg will detect what file format we want to convert to by extension, or we can explicitly specify output file format with-f option.

 3. Conversion video: # only converts 14400 frames-24fps, so this is 10 minutes, that is, the first 10 minutes of input MP4 export ffmpeg-i Mada2_h264_aac_24.mp4-vcodec copy-vframes 14400-acodec copy mada_h264_aac_24.mp4 #-s:size; -R fps; -B bitrate; "Copy" means does not convert, pure copy ffmpeg-i samsung_mpeg4_aac_30.mp4-vcodec h263-s cif-r 30-b 496k-acodec copy samsung_h263_aac_30. 3gpffmpeg-i samsung_mpeg4_aac_30.mp4-vcodec h263p-r 30-b 496k-s qvga-acodec copy samsung_h263p_aac_30.movffmpeg-i s Amsung_mpeg4_aac_30.mp4-vcodec libx264-s qvga-r 30-b 496k-acodec copy samsung_h264_aac_30.mp4 # ffmpeg-i Samsun G_mpeg4_aac_30.mp4-vcodec mpeg2video-s qvga-r 30-b 496k-acodec libmp3lame-ab 192k-ac 2 Samsung_mpeg2_mp3_30.mpg&nbs P;ffmpeg-i mada_h264_aac_24.mp4-vcodec h263-s cif-r 24-b 952k-acodec copy mada_h263_aac_24.3gpffmpeg-i Mada_h264_aa C_24.mp4-vcodec h263p-s 480x272-b 952k-r 24-acodec copy mada_h263p_aac_24.movffmpeg-i mada_h264_aac_24.mp4-vcodec m Peg4-s 480x272-r 24-b 952k-acodec copy Mada_mpeg4_aac_24.mp4 # ffmpeg-i mada_h264_aac_24.mp4-vcodec mpeg2video-s 480x272-b 952k-r 24-acodec libmp3lame-ac 2-ab 192k Mada_ Mpeg2_mp3_24.mpg

There are two points to note: 1. The video size supported by different codec is not the same. h263, for example, does not support QVGA. It doesn't matter if the settings are wrong, FFmpeg will prompt, and will print out all the video size sizes supported by h263. If the audio conversion parameters are wrong, FFmpeg will also print the reason and prompt information, very good.

2. Different file format is required for codec that can be placed in it. For example, MP4 can not be put into H263/mp3. So when the top turns into h263, the output file is 3gp. If file format is wrong, FFmpeg's error message is: [<file format> <function Address>]: Could not find tag ...

That's basically it. FFmpeg is also very useful, especially for converting different media file and codec. Refer to FFmpeg's manual for explanations of each parameter. But FFmpeg now has a lot of problems: for example, a lot of codec are still not supported, like Wmvv3 (WMV9), wmav3 (WMA9) and so on. There are many codec that offer only decoder, not encoder. This is also very painful for the conversion, it is nothing to play. There are some bugs, such as the above command line, when converting to h263p, if the output file format given is 3GP, it will be wrong to say could not find tag ..., in fact, 3GP can be put into h263p, The 3GP on the m.youtube.com is H263++/AMR. So, the above with MOV to replace.

BTW: If you want to convert to wma/wmv words, said before, if it is Wmav1, wmav2, WMVV1, Wmvv2 (that is, Wma7, Wma8, Wmv7, WMV8), using ffmpeg can be done. But if it is wmav3, Wmvv3 (wma9, WMV9), you can only use Microsoft's Windows Media Encoder. Windows Media Encoder requires that the input file be bmp, JPG, MP3, WAV, MPG, AVI, WMV, WMA, ASF, and others are not compatible.

Use FFmpeg to convert media Video

Related Article

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.