Skip to content

Instantly share code, notes, and snippets.

@uupaa
Last active December 25, 2018 19:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uupaa/35bdbcf22be721aea8953ceac2638014 to your computer and use it in GitHub Desktop.
Save uupaa/35bdbcf22be721aea8953ceac2638014 to your computer and use it in GitHub Desktop.
ffmpeg 3.2.4, frei0r 1.4.0 をソースコードからビルドする

ffmpeg 3.2.4, frei0r 1.4.0 をソースコードからビルドする

ffmpeg, frei0r をソースコードからビルドするための環境を用意します

  • ~/.profile を用意し source ~/.profile で適用します

    CFLAGS=`freetype-config --cflags`
    LDFLAGS=`freetype-config --libs`
    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig
    
  • ffmpeg と frei0r のビルドに必要な環境を構築します

    • frei0r-1.4.0 は OpenCV 2.x 系を要求します。3.x 系がインストールされている場合は brew uninstall opencv3 でアンインストールしてください(😵
    • brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 xvid yasm
    • brew install opencv
  • frei0r 1.4.0 のソースコードを取得し展開し、一部を修正します

    • 既に frei0r がインストールされている場合は brew uninstall frei0r でアンインストールしてください
    • https://files.dyne.org/frei0r/releases/ から frei0r-plugins-1.4.0.tar.gz をダウンロードし frei0r-1.4.0 として展開します。    - /usr/ 以下は macOS の制限によりファイルを設置できなくなっています(El Capitan 以降の制限, 例外として /usr/local/ 以下は許可されています)。また brew install opencv で入る xml ファイルが古いフォーマットのため、そのままでは動きません。手動で差し替えます
    • haarcascade_frontalface_default_my.xml の最新版を https://ja.osdn.net/projects/sfnet_magicvisionport/downloads/mvp/cascades/haarcascade_frontalface_default.xml/ からダウンロードし、/usr/local/Cellar/opencv/2.4.13.2/share/OpenCV/haarcascades/haarcascade_frontalface_default_my.xml に設置します
      • OpenCV のインストールパスは brew link opencv で取得できます。パスがズレている場合は上記のパスを適時修正してください

      • frei0r-1.4.0/src/filter/facebl0r/facebl0r.cpp と frei0r-1.4.0/src/filter/facedetect/facedetect.cpp の XMLパスを haarcascade_frontalface_default_my.xml を使うように修正します

        -   register_param("/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml",
        +   register_param("/usr/local/Cellar/opencv/2.4.13.2/share/OpenCV/haarcascades/haarcascade_frontalface_default_my.xml",
                        "Classifier",
                        "Full path to the XML pattern model for recognition; look in /usr/share/opencv/haarcascades");
  • frei0r を make, make install します

    • make install を行うと /usr/local/include/frei0r.h と /usr/local/lib/pkgconfig/frei0r.pc が生成され、ffmpeg の configure で frei0r が認識されるようになります
    • make install を行うと /usr/local/lib/frei0r-1 以下に *.so が生成されます。
    autoheader && aclocal && automake --add-missing --copy && autoconf && ./configure
    make
    make install
    
    > Making install in include
    >  .././install-sh -c -d '/usr/local/include'
    >  /usr/bin/install -c -m 644 frei0r.h '/usr/local/include'
    >  ./install-sh -c -d '/usr/local/share/doc/frei0r-plugins'
    >  ./install-sh -c -d '/usr/local/lib/pkgconfig'
    >  /usr/bin/install -c -m 644 frei0r.pc '/usr/local/lib/pkgconfig'
  • ffmpeg 3.2.4 のソースコードを取得し展開します

    • https://ffmpeg.org/download.html#releases から ffmpeg 3.2.4 の tar を download し、適当な場所に ffmpeg-3.2.4 として展開します

    • ビルドしインストールを行います

      • ./configure の末尾に --enable-frei0r を追加し、frei0r を使用するようにビルドします
      cd ffmpeg-3.2.4
      ./configure --prefix=/usr/local --enable-shared --enable-pthreads --enable-gpl \
      --enable-version3 --enable-hardcoded-tables --enable-avresample \
      --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 \
      --enable-libxvid --enable-opencl --disable-lzma --enable-vda --enable-frei0r
      
      make
      make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment