CentOSにFFMPEG4.3をソースからインストールします。
公式サイトは以下となります。
http://ffmpeg.org/
まずはいきなりFFMPEGをインストールしてみましょう。
1.FFMPEGのインストール
| $ cd /usr/local/src $ wget https://ffmpeg.org/releases/ffmpeg-4.3.tar.gz $ tar -xvzof ffmpeg-4.3.tar.gz $ cd ffmpeg-4.3 $ ./configure --prefix=/usr/local |
上記の configure を実行すると、以下のようなエラーが発生しました。
どうやら nasmが見つからないというエラーです。
とりあえず ffmpegのインストールは脇に置いて、先にnasmをインストールします。
| $ ./configure --prefix=/usr/local nasm/yasm not found or too old. Use --disable-x86asm for a crippled build. If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "ffbuild/config.log" produced by configure as this will help solve the problem. |
2.NASM のインストール
nasmはアセンブラです。今回は nasmの最新である2.15をインストールします。
公式サイトは以下となります。
https://www.nasm.us/
| $ cd /usr/local/src $ wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.gz $ tar xvf nasm-2.15.05.tar.gz $ cd nasm-2.15.05 $ ./configure $ make $ make install |
念のため、nasm が動作するかをコマンドを実行して確認します。
以下のようにメッセージが表示されれば問題ないようです。
| $ nasm: fatal: no input file specified $ Type nasm -h for help. |
3.x264 のインストール
今回、H.264、AACのコーデックのインストールを合わせて行います。 まずは、x264のインストールから行います。
動画をH.264 (MPEG-4 AVC) ビデオストリームへエンコードするためのプログラムです。
| $ cd /usr/local/src $ wget https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.gz $ tar xvf x264-master.tar.gz $ cd x264-master $ ./configure --enable-shared $ make $ make install |
4.AAC のインストール
Fraunhofer 社による FDK オーディオコーデックです。
| $ wget https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.1.tar.gz $ tar xzf fdk-aac-2.0.1.tar.gz $ cd fdk-aac-2.0.1 $ ./configure $ make install |
上記を実行すると、以下のようなメッセージが表示されます。
環境変数 LD_LIBRARY_PATHに設定するか、/etc/ld.so.confに加えるように指示されます。
システム全体に永続的にライブラリを追加したいので、/etc/ld.so.confに加えるようにします。
| Libraries have been installed in: /usr/local/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the '-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the 'LD_RUN_PATH' environment variable during linking - use the '-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to '/etc/ld.so.conf' |
5.環境変数の設定
以下のように ld.so.conf.dディレクトリに usr-local-lib.confというファイルをviで開いて作成します。
| $ cd /etc/ld.so.conf.d $ vi usr-local-lib.conf |
そしてusr-local-lib.confの中に以下のように記入します。
ライブラリを検索する際に、/etc/ld.so.confを直接参照するのではなく、/etc/ld.so.cacheというキャッシュファイルを参照するため、以下のコマンドでこのキャッシュファイルを更新します。
6.FFMPEGのインストール
やっとFFMPEG本体のインストールを行います。 今回は、オプションに x264、aacを指定してconfigureを実行します。
| $ cd /usr/local/src $ wget https://ffmpeg.org/releases/ffmpeg-4.3.tar.gz $ tar -xvzof ffmpeg-4.3.tar.gz $ cd ffmpeg-4.3 $ ./configure --prefix=/usr/local --target-os=linux --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libx264 |
実行すると、以下のようにWARNINGが表示されました。
| WARNING: using libfdk without pkg-config WARNING: using libx264 without pkg-config |
今度は、以下のコマンドを実行してPKG_CONFIG_PATH 環境変数に追加します。
| $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig |
もう一度、 configureを実行しましょう。
| $ cd /usr/local/src $ ./configure --prefix=/usr/local --target-os=linux --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libx264 |
今度は警告は出なくなりました。
続けてmakeを行います。
インストールが完了しました。 ここで、正常に動作しているかを確認してみます。 以下のコマンドでバージョン表示してみます。
以上でFFMPEGの導入は完了となります。