How to Install FFmpeg 3.4 in Ubuntu 16.04

本版討論物聯網 IoT Platform 技術與應用
回覆文章
inho
文章: 49
註冊時間: 2017-12-08, 23:00

How to Install FFmpeg 3.4 in Ubuntu 16.04

文章 inho » 2018-02-03, 13:09

Ubuntu 上安裝ffmpeg在網路上有很多討論,有些安裝過程會出現錯誤,必須花一些時間一一解決,以下,是我從Source cvode 下載、安裝測試還算順利的一種方法:
//*******************************************************************************************
參考網站:http://welkinchen.pixnet.net/blog/post/ ... %9D-ffmpeg
* http://ffmpeg.org/download.html
$ tar -jxvf ffmpeg-3.4.1.tar.bz2
$ cat INSTALL.md
#Installing FFmpeg:
1. Type `./configure` to create the configuration. A list of configure
options is printed by running `configure --help`.
`configure` can be launched from a directory different from the FFmpeg
sources to build the objects out of tree. To do this, use an absolute
path when launching `configure`, e.g. `/ffmpegdir/ffmpeg/configure`.
2. Then type `make` to build FFmpeg. GNU Make 3.81 or later is required.
3. Type `make install` to install all binaries and libraries you built.
NOTICE================
$ ./configure
$ make
$ sudo make install

安裝成功後,會發現在 /usr/local/bin目錄下 多出幾個 新安裝的程式:ffmpeg、ffplay、ffprobe、ffserver. 如果沒有發現 ffplay,表示必須先安裝SDL2(參考本討論區其他相關討論板)
查看ffmpeg 安裝版本:
$ ffmpeg -version
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.6) 20160609
configuration:
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
//********************************************************************************************
================================================================

以下方法也是從source code下載安裝,過程中出現一些錯誤,但是,並沒有完全解決。

https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
============================================================
Note: FFmpeg is part of the Ubuntu packages and can be installed via apt-get install ffmpeg. You may still wish to compile if you want the latest version, experience a bug, or want to customize your build, and it will not interfere with the ffmpeg package in the repository.
============================================================
This guide is designed to be non-intrusive and will create several directories in your home directory:
---------------------------------------------------------------------------------------------------------
ffmpeg_sources – Where the source files will be downloaded. This can be deleted if desired when finished with the guide.
ffmpeg_build – Where the files will be built and libraries installed. This can be deleted if desired when finished with the guide.
bin – Where the resulting binaries (ffmpeg, ffplay, ffserver, x264, x265) will be installed.
=================================================================================
Get the dependencies. These are required for compiling, but you can remove them when you are done if you prefer:
$ sudo apt-get update -qq && apt-get -y install \
autoconf \
automake \
build-essential \
cmake \
git \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtheora-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
mercurial \
pkg-config \
texinfo \
wget \
zlib1g-dev

======================================================
如果安裝有錯誤
./autogen.sh
./autogen.sh: 9: ./autogen.sh: aclocal: not found
./autogen.sh: 10: ./autogen.sh: autoheader: not found
./autogen.sh: 11: ./autogen.sh: automake: not found
./autogen.sh: 12: ./autogen.sh: autoconf: not found
==>You need to install each of the missing packages.
$ sudo apt-get install automake <=== contains autoheader, ...
$ sudo apt-get install autoconf
======= 然後,再執行安裝一次
繼續,...
NASM
An assembler used by some libraries.
==============================================
$ cd ~/ffmpeg_sources && \
wget http://www.nasm.us/pub/nasm/releasebuil ... 02.tar.bz2 && \
tar xjvf nasm-2.13.02.tar.bz2 && \
cd nasm-2.13.02 && \
./autogen.sh && \
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make && \
make install
==============================================
Yasm
An assembler used by some libraries.

If your repository provides yasm version ≥ 1.2.0 then you can install that instead of compiling:

$ sudo apt-get install yasm

Otherwise you can compile:

$ cd ~/ffmpeg_sources && \
wget -O yasm-1.3.0.tar.gz http://www.tortall.net/projects/yasm/re ... 3.0.tar.gz && \
tar xzvf yasm-1.3.0.tar.gz && \
cd yasm-1.3.0 && \
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make && \
make install
==========================================================
libx264
H.264 video encoder. See the H.264 Encoding Guide for more information and usage examples.

Requires ffmpeg to be configured with --enable-gpl --enable-libx264.

If your repository provides libx264-dev version ≥ 118 then you can install that instead of compiling:

$ sudo apt-get install libx264-dev

Otherwise you can compile:

cd ~/ffmpeg_sources && \
git -C x264 pull 2> /dev/null || git clone --depth 1 http://git.videolan.org/git/x264 && \
cd x264 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static && \
PATH="$HOME/bin:$PATH" make && \
make install
---------------------------------- Error --------------------------------------
filters/video/resize.c: In function ‘pick_closest_supported_csp’:
filters/video/resize.c:215:30: error: ‘AVComponentDescriptor {aka const struct AVComponentDescriptor}’ has no member named ‘depth’
if( pix_desc->comp.depth > 8 )
^
Makefile:277: recipe for target 'filters/video/resize.o' failed
make: *** [filters/video/resize.o] Error 1
----------------------------------------------------------------------
======================================================
libx265
H.265/HEVC video encoder. See the H.265 Encoding Guide for more information and usage examples.

If your repository provides libx265-dev version ≥ 68 then you can install that instead of compiling:

$ sudo apt-get install libx265-dev
Otherwise you can compile:

cd ~/ffmpeg_sources && \
if cd x265 2> /dev/null; then hg pull && hg update; else hg clone https://bitbucket.org/multicoreware/x265; fi && \
cd x265/build/linux && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source && \
PATH="$HOME/bin:$PATH" make && \
make install
=============================================================
libvpx
VP8/VP9 video encoder and decoder. See the VP9 Video Encoding Guide for more information and usage examples.

Requires ffmpeg to be configured with --enable-libvpx.

If your repository provides libvpx-dev version ≥ 0.9.7 then you can install that instead of compiling:

$ sudo apt-get install libvpx-dev
Otherwise you can compile:

cd ~/ffmpeg_sources && \
git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \
PATH="$HOME/bin:$PATH" make && \
make install
=================================================================
libfdk-aac
AAC audio encoder. See the AAC Audio Encoding Guide for more information and usage examples.

Requires ffmpeg to be configured with --enable-libfdk-aac (and --enable-nonfree if you also included --enable-gpl).

If your repository provides libfdk-aac-dev then you can install that instead of compiling:

$ sudo apt-get install libfdk-aac-dev
Otherwise you can compile:

cd ~/ffmpeg_sources && \
git -C fdk-aac pull 2> /dev/null || git clone --depth 1 https://github.com/mstorsjo/fdk-aac && \
cd fdk-aac && \
autoreconf -fiv && \
./configure --prefix="$HOME/ffmpeg_build" --disable-shared && \
make && \
make install
--------------------------------------------------------------------------------
Makefile.am:31: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:31: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:31: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:31: If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:31: its definition is in aclocal's search path.
Makefile.am: installing './depcomp'
autoreconf: automake failed with exit status: 1
-------------------------------------------------------------------------------
======================================================================
libmp3lame
MP3 audio encoder.

Requires ffmpeg to be configured with --enable-libmp3lame.

If your repository provides libmp3lame-dev version ≥ 3.98.3 then you can install that instead of compiling:

sudo apt-get install libmp3lame-dev
Otherwise you can compile:

cd ~/ffmpeg_sources && \
wget -O lame-3.100.tar.gz http://downloads.sourceforge.net/projec ... 100.tar.gz && \
tar xzvf lame-3.100.tar.gz && \
cd lame-3.100 && \
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm && \
PATH="$HOME/bin:$PATH" make && \
make install
=====================================================================
libopus
Opus audio decoder and encoder.

Requires ffmpeg to be configured with --enable-libopus.

If your repository provides libopus-dev version ≥ 1.1 then you can install that instead of compiling:

$ sudo apt-get install libopus-dev
Otherwise you can compile:

cd ~/ffmpeg_sources && \
git -C opus pull 2> /dev/null || git clone --depth 1 https://github.com/xiph/opus.git && \
cd opus && \
./autogen.sh && \
./configure --prefix="$HOME/ffmpeg_build" --disable-shared && \
make && \
make install
-------------------------------------------------------------------------------------------------
configure.ac:38: warning: macro 'AM_PROG_LIBTOOL' not found in library
configure.ac:38: error: possibly undefined macro: AM_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
---------------------------------------------------------------------------------------------------
=======================================================================
FFmpeg
cd ~/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
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" \
--extra-libs="-lpthread -lm" \
--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
hash -r
===============================================================================

Compilation is now complete and ffmpeg (also ffprobe, ffserver, lame, and x264) should now be ready to use. The rest of this guide shows how to update or remove FFmpeg.

=======================================================================================
最後由 inho 於 2018-02-03, 15:38 編輯,總共編輯了 1 次。

inho
文章: 49
註冊時間: 2017-12-08, 23:00

Re: How to Install FFmpeg 3.4 in Ubuntu 16.04

文章 inho » 2018-02-03, 14:15

其他Ubuntu 安裝 ffMpeg 參考網站:
1:http://blog.xuite.net/choubee/blog/4148 ... %9D+ffmpeg

2:http://welkinchen.pixnet.net/blog/post/ ... %9D-ffmpeg
* http://ffmpeg.org/download.html
$ tar -jxvf ffmpeg-3.4.1.tar.bz2
$ cat INSTALL.md
#Installing FFmpeg:
1. Type `./configure` to create the configuration. A list of configure
options is printed by running `configure --help`.
`configure` can be launched from a directory different from the FFmpeg
sources to build the objects out of tree. To do this, use an absolute
path when launching `configure`, e.g. `/ffmpegdir/ffmpeg/configure`.
2. Then type `make` to build FFmpeg. GNU Make 3.81 or later is required.
3. Type `make install` to install all binaries and libraries you built.
NOTICE================
$ ./configure
$ make
$ sudo make install

安裝成功後,會發現在 /usr/local/bin目錄下 多出幾個 新安裝的程式:ffmpeg、ffplay、ffprobe、ffserver. 如果沒有發現 ffplay,表示必須先安裝SDL2(參考本討論區其他相關討論板)
查看ffmpeg 安裝版本:
$ ffmpeg -version
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.6) 20160609
configuration:
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100

回覆文章