今まで楽をしようとyumでインストールしていたのですが、今回は下記のサイトを参考に一つ一つ導入してみました。
Compile FFmpeg on CentOS
http://trac.ffmpeg.org/wiki/CompilationGuide/Centos
参考サイトではEncoderにYasm(x264とFFmpegに必要), libx264, libx265, libfdk_aac, libmp3lame, libopus, libogg, libvorbis, libvpxを導入してからffmpegを最後にコンパイルしています。
今回は/usr/local/src/ffmpeg_sourcesを作業場所、インストール先はdefaultの/usr/local/binとします。
- 開発環境
- Yasm
- libx264
- libx265
最初に下記を実行して必要な開発環境を導入しておきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
[root@host01 ~]# yum install autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel 読み込んだプラグイン:fastestmirror インストール処理の設定をしています Loading mirror speeds from cached hostfile * base: ftp.nara.wide.ad.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp パッケージ autoconf-2.63-5.1.el6.noarch はインストール済みか最新バージョンです パッケージ automake-1.11.1-4.el6.noarch はインストール済みか最新バージョンです パッケージ freetype-devel-2.3.11-15.el6_6.1.x86_64 はインストール済みか最新バー ジョンです パッケージ gcc-4.4.7-16.el6.x86_64 はインストール済みか最新バージョンです パッケージ gcc-c++-4.4.7-16.el6.x86_64 はインストール済みか最新バージョンです パッケージ git-1.7.1-3.el6_4.1.x86_64 はインストール済みか最新バージョンです パッケージ libtool-2.2.6-15.5.el6.x86_64 はインストール済みか最新バージョンです パッケージ 1:make-3.81-20.el6.x86_64 はインストール済みか最新バージョンです パッケージ 1:pkgconfig-0.23-9.1.el6.x86_64 はインストール済みか最新バージョンで す パッケージ zlib-devel-1.2.3-29.el6.x86_64 はインストール済みか最新バージョンです 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> Package cmake.x86_64 0:2.8.12.2-4.el6 will be インストール --> 依存性の処理をしています: libarchive.so.2()(64bit) のパッケージ: cmake-2.8.12.2-4.el6.x86_64 ---> Package mercurial.x86_64 0:1.4-4.el6 will be インストール ---> Package nasm.x86_64 0:2.07-7.el6 will be インストール --> トランザクションの確認を実行しています。 ---> Package libarchive.x86_64 0:2.8.3-4.el6_2 will be インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ パッケージ アーキテクチャ バージョン リポジトリー 容量 ================================================================================ インストールしています: cmake x86_64 2.8.12.2-4.el6 base 8.0 M mercurial x86_64 1.4-4.el6 base 1.5 M nasm x86_64 2.07-7.el6 base 386 k 依存性関連でのインストールをします。: libarchive x86_64 2.8.3-4.el6_2 base 126 k トランザクションの要約 ================================================================================ インストール 4 パッケージ 総ダウンロード容量: 10 M インストール済み容量: 37 M これでいいですか? [y/N]y パッケージをダウンロードしています: (1/4): cmake-2.8.12.2-4.el6.x86_64.rpm | 8.0 MB 00:00 (2/4): libarchive-2.8.3-4.el6_2.x86_64.rpm | 126 kB 00:00 (3/4): mercurial-1.4-4.el6.x86_64.rpm | 1.5 MB 00:00 (4/4): nasm-2.07-7.el6.x86_64.rpm | 386 kB 00:00 -------------------------------------------------------------------------------- 合計 1.3 MB/s | 10 MB 00:07 rpm_check_debug を実行しています トランザクションのテストを実行しています トランザクションのテストを成功しました トランザクションを実行しています インストールしています : libarchive-2.8.3-4.el6_2.x86_64 1/4 インストールしています : cmake-2.8.12.2-4.el6.x86_64 2/4 インストールしています : nasm-2.07-7.el6.x86_64 3/4 インストールしています : mercurial-1.4-4.el6.x86_64 4/4 Verifying : cmake-2.8.12.2-4.el6.x86_64 1/4 Verifying : mercurial-1.4-4.el6.x86_64 2/4 Verifying : nasm-2.07-7.el6.x86_64 3/4 Verifying : libarchive-2.8.3-4.el6_2.x86_64 4/4 インストール: cmake.x86_64 0:2.8.12.2-4.el6 mercurial.x86_64 0:1.4-4.el6 nasm.x86_64 0:2.07-7.el6 依存性関連をインストールしました: libarchive.x86_64 0:2.8.3-4.el6_2 完了しました! |
Yasmはx264とFFmpegをコンパイルする時に必要になります。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
[root@host01 ~]# mkdir /usr/local/src/ffmpeg_sources/ [root@host01 ~]# cd /usr/local/src/ffmpeg_sources/ [root@host01 ffmpeg_sources]# git clone --depth 1 https://github.com/yasm/yasm.git Initialized empty Git repository in /usr/local/src/ffmpeg_sources/yasm/.git/ remote: Counting objects: 5176, done. remote: Compressing objects: 100% (3136/3136), done. remote: Total 5176 (delta 2496), reused 3926 (delta 1745), pack-reused 0 Receiving objects: 100% (5176/5176), 5.86 MiB | 1.28 MiB/s, done. Resolving deltas: 100% (2496/2496), done. [root@host01 ffmpeg_sources]# cd yasm/ [root@host01 yasm]# autoreconf -fiv (snip) [root@host01 yasm]# ./configure (snip) [root@host01 yasm]# make (snip) [root@host01 yasm]# make install (snip) test -z "/usr/local/include" || /bin/mkdir -p "/usr/local/include" /usr/bin/install -c -m 644 libyasm.h '/usr/local/include' test -z "/usr/local/share/man/man1" || /bin/mkdir -p "/usr/local/share/man/man1" /usr/bin/install -c -m 644 yasm.1 '/usr/local/share/man/man1' test -z "/usr/local/share/man/man7" || /bin/mkdir -p "/usr/local/share/man/man7" /usr/bin/install -c -m 644 yasm_arch.7 yasm_parsers.7 yasm_dbgfmts.7 yasm_objfmts.7 '/usr/local/share/man/man7' test -z "/usr/local/include/libyasm" || /bin/mkdir -p "/usr/local/include/libyasm" /usr/bin/install -c -m 644 libyasm/arch.h libyasm/assocdat.h libyasm/bitvect.h libyasm/bytecode.h libyasm/compat-queue.h libyasm/coretype.h libyasm/dbgfmt.h libyasm/errwarn.h libyasm/expr.h libyasm/file.h libyasm/floatnum.h libyasm/hamt.h libyasm/insn.h libyasm/intnum.h libyasm/inttree.h libyasm/linemap.h libyasm/listfmt.h libyasm/md5.h libyasm/module.h libyasm/objfmt.h libyasm/parser.h libyasm/phash.h libyasm/preproc.h libyasm/section.h libyasm/symrec.h libyasm/valparam.h libyasm/value.h '/usr/local/include/libyasm' test -z "/usr/local/include" || /bin/mkdir -p "/usr/local/include" /usr/bin/install -c -m 644 libyasm-stdint.h '/usr/local/include' make[3]: ディレクトリ `/usr/local/src/ffmpeg_sources/yasm' から出ます make[2]: ディレクトリ `/usr/local/src/ffmpeg_sources/yasm' から出ます make[1]: ディレクトリ `/usr/local/src/ffmpeg_sources/yasm' から出ます [root@host01 yasm]# make distclean (snip) [root@host01 src]# which yasm /usr/local/bin/yasm [root@host01 yasm]# ls -l /usr/local/bin/ 合計 6288 -rwxr-xr-x. 1 root root 2150775 1月 29 18:26 2016 vsyasm -rwxr-xr-x. 1 root root 2149556 1月 29 18:26 2016 yasm -rwxr-xr-x. 1 root root 2133490 1月 29 18:26 2016 ytasm |
ffmpegをconfigureする時に--enable-gpl --enable-libx264
を追加します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
[root@host01 ~]# cd /usr/local/src/ffmpeg_sources/ [root@host01 ffmpeg_sources]# git clone http://git.videolan.org/git/x264.git Initialized empty Git repository in /usr/local/src/ffmpeg_sources/x264/.git/ [root@host01 ffmpeg_sources]# ls -l 合計 8 drwxr-xr-x. 11 root root 4096 1月 29 18:32 2016 x264 drwxr-xr-x. 15 root root 4096 1月 29 18:26 2016 yasm [root@host01 ffmpeg_sources]# cd x264/ [root@host01 x264]# ./configure --enable-static platform: X86_64 byte order: little-endian system: LINUX cli: yes libx264: internal shared: no static: yes asm: yes interlaced: yes avs: avxsynth lavf: no ffms: no mp4: no gpl: yes thread: posix opencl: yes filters: crop select_every debug: no gprof: no strip: no PIC: no bit depth: 8 chroma format: all You can run 'make' or 'make fprofiled' now. [root@host01 x264]# make (snip) [root@host01 x264]# make install install -d /usr/local/bin install x264 /usr/local/bin install -d /usr/local/include install -d /usr/local/lib install -d /usr/local/lib/pkgconfig install -m 644 ./x264.h /usr/local/include install -m 644 x264_config.h /usr/local/include install -m 644 x264.pc /usr/local/lib/pkgconfig install -m 644 libx264.a /usr/local/lib ranlib /usr/local/lib/libx264.a [root@host01 x264]# make distclean (snip) [root@host01 x264]# which x264 /usr/local/bin/x264 [root@host01 x264]# ls -l /usr/local/bin/ 合計 7740 -rwxr-xr-x. 1 root root 2150775 1月 29 18:26 2016 vsyasm -rwxr-xr-x. 1 root root 1484149 1月 29 18:35 2016 x264 -rwxr-xr-x. 1 root root 2149556 1月 29 18:26 2016 yasm -rwxr-xr-x. 1 root root 2133490 1月 29 18:26 2016 ytasm |
ffmpegをconfigureする時に--enable-gpl --enable-libx265
を追加します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
[root@host01 ~]# cd /usr/local/src/ffmpeg_sources/ [root@host01 ffmpeg_sources]# hg clone https://bitbucket.org/multicoreware/x265 destination directory: x265 requesting all changes adding changesets adding manifests adding file changes added 11291 changesets with 26200 changes to 730 files updating to branch default 253 files updated, 0 files merged, 0 files removed, 0 files unresolved [root@host01 ffmpeg_sources]# cd x265/build/linux/ [root@host01 linux]# cmake -G "Unix Makefiles" -DENABLE_SHARED:bool=off ../../source -- cmake version 2.8.12.2 -- The C compiler identification is GNU 4.4.7 -- The CXX compiler identification is GNU 4.4.7 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detected x86_64 target processor -- Could NOT find NUMA (missing: NUMA_ROOT_DIR NUMA_INCLUDE_DIR NUMA_LIBRARY) -- Looking for include file inttypes.h -- Looking for include file inttypes.h - found -- Performing Test CC_HAS_NO_STRICT_OVERFLOW -- Performing Test CC_HAS_NO_STRICT_OVERFLOW - Success -- Performing Test CC_HAS_NO_NARROWING -- Performing Test CC_HAS_NO_NARROWING - Success -- Performing Test CC_HAS_NO_ARRAY_BOUNDS -- Performing Test CC_HAS_NO_ARRAY_BOUNDS - Success -- Performing Test CC_HAS_FAST_MATH -- Performing Test CC_HAS_FAST_MATH - Success -- Performing Test CC_HAS_STACK_REALIGN -- Performing Test CC_HAS_STACK_REALIGN - Success -- Performing Test CC_HAS_FNO_EXCEPTIONS_FLAG -- Performing Test CC_HAS_FNO_EXCEPTIONS_FLAG - Success -- Found yasm: /usr/local/bin/yasm (found version "1.3.0") -- Found Yasm 1.3.0 to build assembly primitives -- hg found at /usr/bin/hg -- x265 version 1.9+7-dc62b47dd0d9 -- The ASM_YASM compiler identification is unknown -- Found assembler: /usr/local/bin/yasm -- Looking for strtok_r -- Looking for strtok_r - found -- Looking for include file getopt.h -- Looking for include file getopt.h - found -- Configuring done -- Generating done -- Build files have been written to: /usr/local/src/ffmpeg_sources/x265/build/linux [root@host01 linux]# make Scanning dependencies of target common [ 1%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/pixel-a.asm.o [ 2%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/const-a.asm.o [ 3%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/cpu-a.asm.o [ 5%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/ssd-a.asm.o [ 6%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/mc-a.asm.o [ 7%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/mc-a2.asm.o [ 9%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/pixel-util8.asm.o [ 10%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/blockcopy8.asm.o [ 11%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/pixeladd8.asm.o [ 12%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/dct8.asm.o [ 14%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/sad-a.asm.o [ 15%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/intrapred8.asm.o [ 16%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/intrapred8_allangs.asm.o [ 18%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/ipfilter8.asm.o [ 19%] Building ASM_YASM object common/CMakeFiles/common.dir/x86/loopfilter.asm.o [ 20%] Building CXX object common/CMakeFiles/common.dir/x86/asm-primitives.cpp.o [ 22%] Building CXX object common/CMakeFiles/common.dir/vec/vec-primitives.cpp.o [ 23%] Building CXX object common/CMakeFiles/common.dir/vec/dct-sse3.cpp.o [ 24%] Building CXX object common/CMakeFiles/common.dir/vec/dct-ssse3.cpp.o [ 25%] Building CXX object common/CMakeFiles/common.dir/vec/dct-sse41.cpp.o [ 27%] Building CXX object common/CMakeFiles/common.dir/primitives.cpp.o [ 28%] Building CXX object common/CMakeFiles/common.dir/pixel.cpp.o [ 29%] Building CXX object common/CMakeFiles/common.dir/dct.cpp.o [ 31%] Building CXX object common/CMakeFiles/common.dir/ipfilter.cpp.o [ 32%] Building CXX object common/CMakeFiles/common.dir/intrapred.cpp.o [ 33%] Building CXX object common/CMakeFiles/common.dir/loopfilter.cpp.o [ 35%] Building CXX object common/CMakeFiles/common.dir/constants.cpp.o [ 36%] Building CXX object common/CMakeFiles/common.dir/cpu.cpp.o [ 37%] Building CXX object common/CMakeFiles/common.dir/version.cpp.o [ 38%] Building CXX object common/CMakeFiles/common.dir/threading.cpp.o [ 40%] Building CXX object common/CMakeFiles/common.dir/threadpool.cpp.o [ 41%] Building CXX object common/CMakeFiles/common.dir/wavefront.cpp.o [ 42%] Building CXX object common/CMakeFiles/common.dir/md5.cpp.o [ 44%] Building CXX object common/CMakeFiles/common.dir/bitstream.cpp.o [ 45%] Building CXX object common/CMakeFiles/common.dir/yuv.cpp.o [ 46%] Building CXX object common/CMakeFiles/common.dir/shortyuv.cpp.o [ 48%] Building CXX object common/CMakeFiles/common.dir/picyuv.cpp.o [ 49%] Building CXX object common/CMakeFiles/common.dir/common.cpp.o [ 50%] Building CXX object common/CMakeFiles/common.dir/param.cpp.o [ 51%] Building CXX object common/CMakeFiles/common.dir/frame.cpp.o [ 53%] Building CXX object common/CMakeFiles/common.dir/framedata.cpp.o [ 54%] Building CXX object common/CMakeFiles/common.dir/cudata.cpp.o [ 55%] Building CXX object common/CMakeFiles/common.dir/slice.cpp.o [ 57%] Building CXX object common/CMakeFiles/common.dir/lowres.cpp.o [ 58%] Building CXX object common/CMakeFiles/common.dir/piclist.cpp.o [ 59%] Building CXX object common/CMakeFiles/common.dir/predict.cpp.o [ 61%] Building CXX object common/CMakeFiles/common.dir/scalinglist.cpp.o [ 62%] Building CXX object common/CMakeFiles/common.dir/quant.cpp.o [ 63%] Building CXX object common/CMakeFiles/common.dir/deblock.cpp.o [ 63%] Built target common Scanning dependencies of target encoder [ 64%] Building CXX object encoder/CMakeFiles/encoder.dir/analysis.cpp.o [ 66%] Building CXX object encoder/CMakeFiles/encoder.dir/search.cpp.o [ 67%] Building CXX object encoder/CMakeFiles/encoder.dir/bitcost.cpp.o [ 68%] Building CXX object encoder/CMakeFiles/encoder.dir/motion.cpp.o [ 70%] Building CXX object encoder/CMakeFiles/encoder.dir/slicetype.cpp.o [ 71%] Building CXX object encoder/CMakeFiles/encoder.dir/frameencoder.cpp.o [ 72%] Building CXX object encoder/CMakeFiles/encoder.dir/framefilter.cpp.o [ 74%] Building CXX object encoder/CMakeFiles/encoder.dir/level.cpp.o [ 75%] Building CXX object encoder/CMakeFiles/encoder.dir/nal.cpp.o [ 76%] Building CXX object encoder/CMakeFiles/encoder.dir/sei.cpp.o [ 77%] Building CXX object encoder/CMakeFiles/encoder.dir/sao.cpp.o [ 79%] Building CXX object encoder/CMakeFiles/encoder.dir/entropy.cpp.o [ 80%] Building CXX object encoder/CMakeFiles/encoder.dir/dpb.cpp.o [ 81%] Building CXX object encoder/CMakeFiles/encoder.dir/ratecontrol.cpp.o [ 83%] Building CXX object encoder/CMakeFiles/encoder.dir/reference.cpp.o [ 84%] Building CXX object encoder/CMakeFiles/encoder.dir/encoder.cpp.o [ 85%] Building CXX object encoder/CMakeFiles/encoder.dir/api.cpp.o [ 87%] Building CXX object encoder/CMakeFiles/encoder.dir/weightPrediction.cpp.o [ 87%] Built target encoder Scanning dependencies of target x265-static Linking CXX static library libx265.a [ 87%] Built target x265-static Scanning dependencies of target cli [ 88%] Building CXX object CMakeFiles/cli.dir/input/input.cpp.o [ 89%] Building CXX object CMakeFiles/cli.dir/input/yuv.cpp.o [ 90%] Building CXX object CMakeFiles/cli.dir/input/y4m.cpp.o [ 92%] Building CXX object CMakeFiles/cli.dir/output/output.cpp.o [ 93%] Building CXX object CMakeFiles/cli.dir/output/reconplay.cpp.o [ 94%] Building CXX object CMakeFiles/cli.dir/output/yuv.cpp.o [ 96%] Building CXX object CMakeFiles/cli.dir/output/y4m.cpp.o [ 97%] Building CXX object CMakeFiles/cli.dir/output/raw.cpp.o [ 98%] Building CXX object CMakeFiles/cli.dir/x265.cpp.o [100%] Building CXX object CMakeFiles/cli.dir/x265-extras.cpp.o Linking CXX executable x265 [100%] Built target cli [root@host01 linux]# make install [ 63%] Built target common [ 87%] Built target encoder [ 87%] Built target x265-static [100%] Built target cli Install the project... -- Install configuration: "Release" -- Installing: /usr/local/lib/libx265.a -- Installing: /usr/local/include/x265.h -- Installing: /usr/local/include/x265_config.h -- Installing: /usr/local/lib/pkgconfig/x265.pc -- Installing: /usr/local/bin/x265 [root@host01 linux]# ll /usr/local/bin/ 合計 12468 -rwxr-xr-x. 1 root root 2150775 1月 29 18:26 2016 vsyasm -rwxr-xr-x. 1 root root 1484149 1月 29 18:35 2016 x264 -rwxr-xr-x. 1 root root 4839997 2月 2 14:09 2016 x265 -rwxr-xr-x. 1 root root 2149556 1月 29 18:26 2016 yasm -rwxr-xr-x. 1 root root 2133490 1月 29 18:26 2016 ytasm |