3. Install ffmpeg under ubuntu

One: apt-get is installed from the network;
1. Ensure that ubuntu can connect to the network:

2. Execute the following commands in sequence:
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg

3. Check whether the installation is successful:
ffmpeg -version

aston@ubuntu:/mnt/hgfs/share/leixiaohua_video_audio_encode/test3$ ffmpeg -version
ffmpeg version 2.4.3-1ubuntu1~trusty6 Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 22 2014 17:07:19 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/usr --extra-version='1ubuntu1~trusty6' --build-suffix=-ffmpeg --toolchain=hardened --extra-cflags= --extra-cxxflags= --libdir=/usr/lib/i386-linux-gnu --shlibdir=/usr/lib/i386-linux-gnu --incdir=/usr/include/i386-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-opengl --enable-x11grab --enable-libxvid --enable-libx265 --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv

libavcodec     56.  1.100 / 56.  1.100	//1.编解码(最重要的库);
libavformat    56.  4.101 / 56.  4.101	//2.封装格式处理;
libavfilter     5.  1.100 /  5.  1.100	//3.滤镜特效处理;	
libavdevice    56.  0.100 / 56.  0.100	//4.各种设备的输入输出;
libavutil      54.  7.100 / 54.  7.100	//5.工具库(大部分库都需要这个库的支持);	
libpostproc    53.  0.100 / 53.  0.100	//6.后加工
libswresample   1.  1.100 /  1.  1.100	//7.音频采样数据格式转换;
libswscale      3.  0.100 /  3.  0.100	//8.视频像素数据格式转换;
libavresample   2.  1.  0 /  2.  1.  0	//9.

4. Success.

Two: Manual installation of the official website download library:
//Install ffmpeg:
1. Obtain the FFmpeg source code:
Download: http://ffmpeg.org/download.html File location: C:\Users\86150\Desktop\Record\package\ffmpeg- 4.1.4.tar.bz2
New folder: Create a new ffmpeg folder under /usr/local/:
Unzip the source code to this folder:
tar -jxvf /mnt/hgfs/share/packages/ffmpeg-4.1.4.tar .bz2 -C /usr/local/ffmpeg

2. Enter the folder: /usr/local/ffmpeg/ffmpeg-4.1.4
1. Configuration:
./configure --enable-shared --disable-x86asm --prefix=/usr/local/ffmpeg
//–enable -shared // Compile the shared library, the default is static library
//--disable-x86asm // Do not use x86asm, the default yasm configuration will be very troublesome, you need to download x86asm // You can also use --enable, haven't tried it
//-- prefix=/usr/local/ffmpeg //After the compilation is complete, output the file path we want to use
2. Compile:
make //The process is very long, it takes about half an hour;
3. Installation: After the
make install is
successful, it can be in the installation directory Relevant library files, header files and executable programs are found under;
root@ubuntu:/usr/local/ffmpeg# ls
bin ffmpeg-4.1.4 include lib share

3. If compile error: library file not found:
/usr/bin/ld: warning: libswresample.so.3, needed by /usr/local/ffmpeg/lib/libavcodec.so, not found (try using -rpath or -rpath-link)
Reason:
The path of the link library is specified in the Makefile, but it is not found under this path;
-L /usr/local/ffmpeg/lib -lavformat -lavcodec -lavutil -lswscale
Solution:
Add the environment variable of the link library :
Sudo vim /etc/profile
add at the back:
export LD_LIBRARY_PATH= LDLIBRARYPATH: / usr / local / ffmpeg / lib After saving, source it: source / etc / profile Check: aston @ ubuntu: / mnt / hgfs / share / sourceinsight / main 1 7 / M ain Code LD_LIBRARY_PATH:/usr/local/ffmpeg/lib After saving, source: source /etc/profile Check: aston@ubuntu:/mnt/hgfs/share/source_insight/main_17/MainCodeLDLIBRARYPA T H:/ U S R & lt / L O C A L / F F m P E G / L I B holding stored after S O U R & lt C E a case : S O U R & lt C E / E T C / P R & lt O F I L e inspection check : A S T O n- @ Ub u n t u:/mnt/hgfs/share/sourceinsight/main17/MainCode echo $LD_LIBRARY_PATH
:/usr/local/ffmpeg/lib
成功;

4. Success.

Three:
Compile the dynamic library and static library of ffmpeg:
#CFLAGS += -g -w -static
CFLAGS += -g -w
#CFLAGS += -g
1. When the Makefile does not specify which library to use, it is used by default Dynamic library; use static library to add -static

2. When SDL uses a dynamic library;
what is the library link path that ffmpeg sees and what library is used;
when using a dynamic library, the generated files are small, but the link library path must be specified when the program is running (That is the 3 of the above step: $LD_LIBRARY_PATH)

Guess you like

Origin blog.csdn.net/yanghangwww/article/details/102865608