FFmpeg compiled under Linux

Source: Internet
Author: User


2012-06-25 19:36:06 |   Category:   default category | report | font size   subscription

1, download ffmpeg.

wget http://down1.chinaunix.net/distfiles/ffmpeg-0.4.9-p20051120.tar.bz2

I am on this website download ffmpeg-0.4.9-p20051120.tar.bz2, see someone on the Internet is svn download, but my machine does not have SVN client, and then on the Internet search, download this version. If you use SVN, you can download the latest version of FFmpeg.

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

2. Decompression

tar xvfj ffmpeg-0.4.9-p20051120.tar.bz2

get the extracted directory is ffmpeg-0.4.9-p20051120, the name is too long, using the MV command to change to FFmpeg

MV ffmpeg-0.4.9-p20051120.tar.bz2 FFmpeg

3. Configuration

./configure--enable-shared--prefix=/usr/local/ffmpeg

Where:--enable-shared is allowed to compile the dynamic library, in the future programming to use this several dynamic libraries. --prefix set the installation directory.

4. Compile and install

Make
Make Install

5, after installation in/usr/local/ffmpeg will see that there are three directories

lib dynamic link library location
include programming to use the header file
the directory where the bin execution file resides

6, in order to facilitate the programming later, we put Lib three link library libavcodec.so libavformat.so libavutil.so copy to/usr/lib. Copy the FFmpeg directory under the Include directory to/usr/include.

here I copied or not, when-lavcodec-lavutil-lavformat, I was prompted not to find the libraryand then I'll copy all the/usr/local/ffmpeg/lib files to/usr/local/lib.
execute the Ffplay in the bin directory to play audio or video files. For example, play 1.mp3

./ffplay 1.mp3

In addition, there are two files in the bin directory: FFmpeg and Ffserver

FFmpeg is a good video and audio format conversion tool. There are a lot of its documentation on the Web. If you do not want to generate ffserver, just add--disable-ffserver to the./configure.

7. Programming

If you write a test.c file, to include the FFmpeg header file, you can write:

#include

compile: Gcc-o test Test.c-lavformat-lavcodec-lavtuil (if there is a 6th step operation)

If there is no 6th operation, the compile time is as follows:

gcc-o Test Test.c-i/usr/local/ffmpeg/include-l/usr/local/ffmpeg/lib-lavformat-lavcodec-lavtuil

after the success of the compilation, it is necessary to implement the dynamic library support, or to copy the three dynamic library files to/usr/lib or/lib, or the execution will say that the dynamic library link is not found. There is another way to solve this problem is to add the/usr/local/ffmpeg/lib directory to the/etc/ld.so.config, and then execute ldconfig, or restart the computer, so that the system can be executed from the/usr/local/ Ffmpeg/lib This directory down to find the three dynamic library files.

The above way is the use of dynamic library compiled ffmpeg, if the Configure time without adding--enable-shared, then the static link in the way, will not generate those three dynamic library. At the same time the generated ffplay, ffmpeg execution files are also relatively large, because they do not need the support of the dynamic library, it can be executed. However, it is not conducive to re-development, so I use dynamic link way. There are also many options in configure, which can be viewed through the./configure--help, or you can view the configure file directly. This is important when configuring.

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.