FFmpeg Linux under compilation

Source: Internet
Author: User
Tags bz2

Note: Transfer from others, the source does not know.

1. Install the Linux base environment

The basic environment is the basic library of compiled code, Ubuntu networking installation software is very simple, a statement can be done, here are the following statements:

# apt-get -y install autoconf automake build-essential libtool libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
2. Installing dependent libraries

Depending on the library, you can refer to the dependent library information listed on the following Web site, and the version selected in this article is referenced on this page: FFmpeg Dependent library information

2.1 FFmpeg recommended Dependency Development Library (no standalone installation required)
# apt-get -y install libass-dev libfreetype6-dev libmp3lame-dev libtheora-dev libvorbis-dev libopus-dev libx264-dev yasm
2.2 FFmpeg Desktop app recommended dependency Development library (no standalone installation required)
# apt-get -y install libva-dev libvdpau-dev libsdl2-dev
2.3 Dependent development libraries requiring stand-alone installation

First create FFmpeg code directory, all the source code is placed in this directory

# mkdir ~/ffmpeg_sources
2.3.1 Installing fdk-aac-0.1.5:
# cd ~/ffmpeg_sources# wget http://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.5.tar.gz# tar -zxvf fdk-aac-0.1.5.tar.gz && mv fdk-aac-0.1.5 fdk-aac# cd fdk-aac# ./configure --prefix="$HOME/ffmpeg_build" --disable-shared# make# make install# make distclean
2.3.2 Installing libvpx-1.6.1:
# cd ~/ffmpeg_sources# wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.1.tar.bz2# tar -jxvf libvpx-1.6.1.tar.bz2 && mv libvpx-1.6.1 libvpx# cd libvpx# PATH="$HOME/bin:$PATH"# ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests# PATH="$HOME/bin:$PATH"# make # make install# make distclean
2.3.3 Installing x265-2.4:
# cd ~/ffmpeg_sources# sudo apt-get install cmake mercurial# wget https://bitbucket.org/multicoreware/x265/downloads/x265_2.4.tar.gz# tar -zxvf x265_2.4.tar.gz && mv x265_2.4 x265# cd x265/build/linux# PATH="$HOME/bin:$PATH"# cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source# make # make install# make clean
2.3.4 Installing x264:
# cd ~/ffmpeg_sources# wget  https://download.videolan.org/x264/snapshots/x264-snapshot-20170822-2245-stable.tar.bz2# tar -jxvf x264-snapshot-20170822-2245-stable.tar.bz2 && mv x264-snapshot-20170822-2245-stable x264# ./configure --prefix="$HOME/ffmpeg_build" --enable-shared --enable-pic# make# make install# make distclean
3. Compiling ffmpeg
# cd ~/ffmpeg_sources# wget http://ffmpeg.org/releases/ffmpeg-3.3.3.tar.xz# tar -Jxvf ffmpeg-3.3.3.tar.xz && mv ffmpeg-3.3.3 ffmpeg# cd ffmpeg# PATH="$HOME/bin:$PATH"# export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"# ./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree# PATH="$HOME/bin:$PATH"# make# make install# make distclean# hash -r

After the FFmpeg is compiled, it can be used. Compile generated executable program in ~/bin directory

Note: The above./configure configuration is not debug after compilation and requires the following configuration:

# PATH="$HOME/bin:$PATH"# export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-debug --disable-asm --disable-stripping
4. Installing the JDK

Although the whole process is compiled in C + +, installing Eclipse requires a JDK environment, so install the JDK first.

4.1 First look at the number of system bits:
getconf LONG_BIT
4.2 Download Extract JDK Package

My system is a 32-bit system that downloads 32-bit JDK packages from the JDK website http://www.oracle.com/technetwork/java/javase/downloads/ jdk8-downloads-2133151.html), download here is jdk-8u144-linux-i586.tar.gz, unzip:

# mkdir ~/Java# tar -zxvf jdk-8u144-linux-i586.tar.gz -C ~/Java/
4.3 Setting environment variables
# sudo vim /etc/profile

Write the code at the end (XXX is the user name, which is the login account)

export JAVA_HOME=/home/rong/Java/jdk1.8.0_152export JRE_HOME=$JAVA_HOME/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

Make environment variables effective

source /etc/profile
4.4 Viewing the JDK versions that are already in the system
# sudo update-alternatives --config java# sudo update-alternatives --config javac# sudo update-alternatives --config javaws
4.5 Setting the system default JDK
# sudo update-alternatives --install /usr/bin/java java /home/rong/Java/jdk1.8.0_144/bin/java 2000# sudo update-alternatives --install /usr/bin/javac javac /home/rong/Java/jdk1.8.0_144/bin/javac 2000# sudo update-alternatives --install /usr/bin/javaws javaws /root/Java/jdk1.8.0_144/bin/javaws 2000
4.6 View Java version, if you see the same as the installation, the installation is successful
# java -version
5. Install Eclipse5.1 Download Eclipse

Download the exlipse from the official website and choose to download the C/D + + development version of Linux: Eclipse

5.2 Decompression
# tar -zxvf eclipse-cpp-neon-3-linux-gtk-x86_64.tar.gz && mv eclipse ~/
5.3 Using Eclipse

Eclipse can be used directly after decompression

# cd ~/eclipse# ./eclipse
5.3 Configuring Eclipse
    • From the Eclipse menu, choose Help, install new software
    • Click on the "Add ..." button and add the following software source address
      http://download.eclipse.org/tools/cdt/releases/9.2, and named CDT. Here's a look at your eclipse version and you can click
      Help--About Eclipse SDK View and find the appropriate URL on the following website: http://www.eclipse.org/cdt/downloads.php.
    • After selecting OK, you can see that we are asked to select the software to install. In fact, the installation of the CDT Main Features and the CDT Optional Features in the GCC, and some of the options are also dependent on other libraries may not be installed,
      It won't work if it's loaded. But there's no need to waste time here, you've got to choose.
    • Then select "Next-and next-finsh" to start the installation, after the installation, will pop up the following requirements to restart the Eclipse prompt box. Click Yes to restart Eclipse so the installation is successful. After rebooting, you can create a new C + + project.

It is also important to note that when compiling C + +, we should pay attention to configuring the path of the compiler and the path of the C + + runtime by opening windows->preference->c/c++->environment:

C_INCLUDE_PATH=/usr/includeC_PLUS_INCLUDE_PATH=/usr/include/c++/4.8.4

Where/usr/include/c++/4.6.3 is the path where the C + + compiler is located.

6. Establishment of FFMPEG project

Select New-> Makefile Project from existing code, in the Pop-up dialog box, select the Codes directory, set the project name, select Liuux gcc as the compiler, OK.

To compile the project, after re-executing the config command, you can right-click the project name and click Build Project to complete the compilation process.

To add parameters to your program: Right-click the project name, select the Arguments tab in Debug configerations, Run as, select FFmpeg, add-I 01.mp4 01.mkv, and you can convert the format.

will be 01. MP4 files are copied so far that the program can run through Eclipse.

7. FFmpeg Code Debug

Just the project can be run, but not debug. To resolve this problem, first identify a point, the generated executable program, FFmpeg does not contain debug information, debug information in Ffmpeg_g, debug to select Ffmpeg_g.

In addition, the./config option also determines the core that contains the debug information, depending on the information on the web, the main points to note. Need to add in config:

    • –enable-debug=3 Open Debug Debug
    • –DISABLE-ASM Disabling ASM Optimizations
    • –disable-optimize Disabling optimizations
    • –disable-stripping Disabling stripping of executable programs and shared libraries

Use the following command to reconfigure the Config

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-debug=3 --disable-asm --disable-stripping

--enable-version3--disable-optimizations--disable-asm--enable-shared--enable-pic

PATH="/home/rong/bin:$PATH" PKG_CONFIG_PATH="/home/rong/ffmpeg_build/lib/pkgconfig" ./configure   --prefix="/home/rong/ffmpeg_build"   --pkg-config-flags="--static"   --extra-cflags="-I/home/rong/ffmpeg_build/include"   --extra-ldflags="-L/home/rong/ffmpeg_build/lib"   --bindir="/home/rong/bin"   --enable-gpl   --enable-libass   --enable-libfdk-aac   --enable-libfreetype   --enable-libmp3lame   --enable-libopus   --enable-libtheora   --enable-libvorbis   --enable-libvpx   --enable-libx264   --enable-libx265   --enable-nonfree   --enable-pthreads   --enable-debug=3   --disable-optimizations   --disable-asm   --disable-stripping

Right-click the project name and click Build Project to complete the compilation process. Add parameters to the program: right-click the project name, debug as-debug Configerations Select the Arguments tab, select Ffmpeg_g, add-I 01.mp4 01.mkv, you can implement Debug.

What about the source code we want? In fact, do a simple operation can: click on the upper right corner of the debug front button and select C + +, you can see the C code. Four control keys used during commissioning:

    • F5: One-step debugging, the function is encountered inside the function, equivalent to the F11 of VS;
    • F6: Single-step debugging, the function is skipped, equivalent to the F10 of VS;
    • F7: Single-step debugging, jumping out of the current method, equivalent to the shift+f11 in VS;
    • F8: Debug the Run program until the first breakpoint, equivalent to the F5 in vs.

FFmpeg Linux under compilation

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.