LoginSignup
16
14

More than 5 years have passed since last update.

[FFmpeg] ffmpeg に libx265 をリンクする

Last updated at Posted at 2014-09-17

2015-09-03 編集

この記事は ffmpeg Advent Calendar 2014 - Qiita の初日です。
初投稿。よろしくお願いします。

-- 以下本文

ffmpegがlibx265 エンコードに対応していたので更新

x265 のインストール

x265 wiki

hg バージョン確認

$ hg --version
Mercurial Distributed SCM (version 1.4)

Copyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

hg なければインストール

# yum install mercurial-1.4-3.el6.x86_64

libx265 ダウンロード

$ hg clone https://bitbucket.org/multicoreware/x265

cmake のバージョン確認

$ cmake -version
cmake version 2.8.8

x265のコンパイル時に警告された場合は更新する

libx265 ビルド/インストール

$ cd x265/build
$ cmake .
$ make
# make install

2015-09-03 現在

$ cd x265/build/linux
$ ./make-Makefiles.bash

BIN_INSTALL_DIR      -> /usr/local/bin
CMAKE_INSTALL_PREFIX -> /usr
LIB_INSTALL_DIR      -> /usr/local/lib

$ make
# make install
[ 63%] Built target common
[ 87%] Built target encoder
[ 87%] Built target x265-shared
[100%] Built target cli
[100%] Built target x265-static
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libx265.a
-- Installing: /usr/include/x265.h
-- Installing: /usr/include/x265_config.h
-- Installing: /usr/local/lib/libx265.so.74
-- Installing: /usr/local/lib/libx265.so
-- Installing: /usr/local/lib/pkgconfig/x265.pc
-- Installing: /usr/local/bin/x265
-- Removed runtime path from "/usr/local/bin/x265"

ffmpeg のインストール

download

$ git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
or
$ cd ffmpeg
$ git pull

プロキシ経由する場合は

$ git config --global https.proxy https://[host]:[port]/
$ git clone https://github.com/FFmpeg/FFmpeg ffmpeg

ffmpeg configure

下記は、最低限の設定です。

$ cd ffmpeg
$ ./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-static \
--disable-shared \
--enable-libx265 \
--extra-cflags="-I/usr/local/include -I/usr/include" \
--extra-ldflags="-L/usr/local/lib" \
--enable-memalign-hack

[Error] x265 NOT FOUND

x265.h がエラーしてるっぽい。

# vi /usr/local/include/x265.h
  • 117行目あたり
/* Stores inter (motion estimation) analysis data for a single frame */
- struct x265_inter_data
+ typedef struct x265_inter_data
{
    uint32_t zOrder;
    int      ref[2];
    int      costZero[2];
    int16_t  mvx[2];
    int1y[2];
    uint32_t depth;
    int      poc;
    uint32_t cuAddr;
- };
+ } x265_inter_data;

/* Stores intra (motion estimation) analysis data for a single frame */
- struct x265_intra_data
+ typedef struct x265_intra_data
{
    uint8_t*  depth;
    uinmodes;
    char*     partSizes;
    int*      poc;
    uint32_t* cuAddr;
- };
+ } x265_intra_data;

/* Stores all analysis data for a single frame */
- struct x265_analysis_data
+ typedef struct x265_analysis_data
{
    x265_inter_data* interData;
    x265_intra_data* intraData;
    uint32_t         numCUsInFrame;
    uint32_t         numPartitions;
- };
+ } x265_analysis_data;

[Error] AVFoundation/AVFoundation.h file not found

gcc-objc がないらしい

2015-09-03 現在
間違っていそうなので調査中。

# yum install gcc-objc

[Error] x265.pc not found

$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

2015-09-03 現在
エラーメッセージが変更されている
x265 not found

./configureが通ったら

$ make
$ ./ffmpeg -version
ffmpeg version N-68129-g928322c Copyright (c) 2000-2014 the FFmpeg developers
built on Dec  1 2014 16:38:07 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
configuration: --prefix=/usr/local --enable-gpl --enable-version3 --enable-nonfree --enable-static --disable-shared --enable-libx265 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-memalign-hack
libavutil      54. 15.100 / 54. 15.100
libavcodec     56. 13.100 / 56. 13.100
libavformat    56. 15.101 / 56. 15.101
libavdevice    56.  3.100 / 56.  3.100
libavfilter     5.  2.103 /  5.  2.103
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100

ライブラリが正しくリンクされているかどうかの確認

$ ldd ./ffmpeg
[root@studiowebserv ffmpeg]# ldd ./ffmpeg
        linux-vdso.so.1 =>  (0x00007fff5a5ff000)
        libx265.so.38 => /usr/local/lib/libx265.so.38 (0x00007f4a29734000)
        libm.so.6 => /lib64/libm.so.6 (0x00000033a8e00000)
        libz.so.1 => /lib64/libz.so.1 (0x00000033a9a00000)
        librt.so.1 => /lib64/librt.so.1 (0x00000033a9e00000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00000033a9200000)
        libc.so.6 => /lib64/libc.so.6 (0x00000033a8a00000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000033af200000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000033ae200000)
        /lib64/ld-linux-x86-64.so.2 (0x00000033a8600000)

[Error] libx265.so.38 not found

確認事項

$ cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib

# ldconfig -v

インストール

# make install

$ ffmpeg -codecs | grep libx265

 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (encoders: libx265 )

以上。
FFmpegや各種ライブラリは、どんどんアップデートされますので、
上記方法でコンパイルできなくなることがあります。
ご了承ください。

16
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14