FFmpeg installing a third-party encoder (encoder) library, ffmpeg encoding H264 (end)

Source: Internet
Author: User
Tags git clone

FFmpeg installing a third-party encoder (encoder) Library

Keywords: ffmpeg, code H264, third party encoder

After installing the FFmpeg, if you use the FFmpeg tool to turn a video file into H264 video encoding, MP3 audio encoding or other ffmpeg itself without the XXX encoding type, you will see the error message, unknown encoder ' xxx '. Now all you need is to install the other encoder on the line, essentially the other encoder in the form of a library installation, for example, the correct libx264.so or libx264.a stored under the/usr/lib under Or/usr/local/lib.

For two examples, the video encoder takes H264 For example, the audio aspect takes MP3 (mp3lame).

Literacy, Linux installation of a formal software, is generally the trilogy, ①, "./configure" (add some possible parameters, such as enable some features, disable some features, what can be turned on and off. Generally through the./configure--help command to query), ②, "make" (compile), ③, "Sudo made Install" (copy the generated binary application files and. So and. A to/usr/local/)

First, H264

Do a search of FFmpeg's engineering code base, you will find each codec have a few member variables, but there are several codec missing encoder,h264 is one of them. For whatever reason, FFmpeg does not have native support H264, but you can check avcodec_register_all this API, you will find a large register_encoder (xxx, XXX)

Register_decoder (xxx, XXX)

There are lots of blocks here, such as/* Video codecs */,/* audio codecs */,/* external libraries * *

But you are in/* Video codecs */this piece but can not see H264 register_endecoder (H264, h264); This sentence, if you insist on the upside down, you will be in/* External libraries * * This piece found Register_encoder (LIBX264, libx264); So FFmpeg has an interface ready for H264, but requires a third-party library to support it.

Back to the point, how to install it.

1. Download the x264 Project code First, "Git clone git://git.videolan.org/x264.git".

2. Go to the x264 directory, and then./configure--help Look at its help information, what we need here is x264 to support ffmpeg in the form of. So or. A, so it's common to focus on shared and static keywords. Execute./configure--enable-shared--enable-static on the line.

3. Make && sudo made install.

You will find that we did not specify the prefix in the./configure--prefix=/usr, it is clear that libx264.so and libx264.a will be copied to/usr/local/lib, remember here, and so on, because there are some changes to make.

Second, Mp3lame

Above said H264, believe that mp3lame understanding is much simpler.

1. First download Mp3lame Engineering code, http://sourceforge.net/projects/lame/files/lame/, why here to appear redundant talk about Mp3lame, is this. You can see x264 use is Git,mp3lame is used SourceForge, may wish to say a FAAC (also a native ffmpeg not support audio codec), FAAC with http://sourceforge.net/ projects/faac/files/faac-src/, so each codec or very important software has a team or community in the maintenance, so need something, try to go to SourceForge or git to find, other places may not be new, may not be complete correctly.

2. Then also./configure--help first, see what features we need to turn off the

3. Make && sudo made install.

Obviously, we didn't specify--PREFIX-/USR, so Mp3lame's libmp3lame.so and Libmp3lame.a were assigned to/usr/local/lib.

Third, recompile ffmpeg

1. Enter the FFmpeg directory,./configure--ENABLE-GPL--enable-libx264--enable-libmp3lame, and a new makefile is generated.

2. Execute sudo make, clean && make sudo make install.

3. So FFmpeg is recompiled, finished can be verified, using the FFmpeg tool, a video file in the video stream code into h264 format, audio stream code into mp3lame format, you may try.

4. If you are really trying, you should see an error similar to "libxxx.so not found", the solution is as follows:

(1). Appearance: FFmpeg running when trying to link libxxx.so, but can not find the corresponding libxxx.so.

(2). Doubt: I had installed libxxx.so before.

(3). Reason: The program runs the default is to go to/usr/lib under the libxxx.so, but we installed before the/usr/local/lib, so caused this error.

(4). Solution: There are many, I said a kind of I have tested.

Add a line of/etc/ld.so.conf to the/etc/ld.so.conf file, of course, with the root user. Then execute the ldconfig command to make the changes to take effect, and then run the FFmpeg transcoding command to try, OK.

Before I tried to use Ffplay to play a h264 encoded video, the result is of course can play, I naively thought ffmpeg support h264, in fact, ffmpeg is mainly used to decode, so some format encoder but not, so there will be third-party library support, Why does native ffmpeg not support certain formats? Cause I don't know for a moment. In order to solve ffmpeg can encode h264 This problem, I search some information on the Internet, and then summed up as above, in the process I also harvested some knowledge of Linux, has been written.

May 28, 2012 16:05:15

form:http://hi.baidu.com/y11022053/item/6d4c34ba87c7b5f362388e9a

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.