mpvプレーヤーをコンパイルする
mpvという名前の動画プレーヤーがある。かってVLCとしのぎを削ったmplayer/mplayer2の流れを汲むソフトだ。
筆者も長い間VLCを使ってきた。だが、ブルーレイディスクの再生時に音が途切れたりするのと、余計なファイルタイプまで開けると主張するのがうるさく、別のソフトを探していた。そこに現れたのがmpvである。
本稿では、そのmpvを利用するにあたってのコンパイル方法について述べる。(最終更新日:2022.05.20)
-
ディスクイメージの作成
始めにディスクユーティリティを用いてmpv_compile
というボリューム名のディスクイメージを作る。容量は4GBもあれば十分である。 -
環境変数のセット
export VOLNAME=mpv_compile export TARGET="/Volumes/${VOLNAME}" export SRC="${TARGET}/src" export CMPL="${TARGET}/compile" export PATH=${TARGET}/bin:$PATH mkdir -p ${CMPL} mkdir -p ${SRC} export PKG_CONFIG_PATH=${TARGET}/lib/pkgconfig export LIBTOOL=`which glibtool` export LIBTOOLIZE=`which glibtoolize` #macOS Ctalina以降向け export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
git pullでvimエディタが開くのを防止(1回のみ)
echo 'export GIT_MERGE_AUTOEDIT=no' >> $HOME/.bash_profile && . $HOME/.bash_profile
-
pkg-configのコンパイル&インストール
cd ${SRC} curl -LO https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz cd ${CMPL} tar xf ${SRC}/pkg-config-0.29.2.tar.gz cd pkg-config-0.29.2 ./configure --with-internal-glib make && sudo make install
-
nasmのコンパイル&インストール(ffmpeg, libass等のコンパイルに用いる)
cd ${SRC} curl -LO https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz cd ${CMPL} tar xf ${SRC}/nasm-2.15.05.tar.xz cd nasm-2.15.05 ./configure --prefix=/usr/local make && sudo make install
-
autoconfのコンパイル&インストール(fribidiのコンパイルに用いる)
cd ${SRC} curl -LO https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz cd ${CMPL} tar xf ${SRC}/autoconf-2.71.tar.xz cd autoconf-2.71 ./configure make && sudo make install
-
automakeのコンパイル&インストール(fribidiのコンパイルに用いる)
cd ${SRC} curl -LO https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.xz cd ${CMPL} tar xf ${SRC}/automake-1.16.5.tar.xz cd automake-1.16.5 ./configure make && sudo make install
-
libtoolのコンパイル&インストール(fribidiのコンパイルに用いる)
cd ${SRC} curl -LO http://ftp.jaist.ac.jp/pub/GNU/libtool/libtool-2.4.6.tar.xz cd ${CMPL} tar xf ${SRC}/libtool-2.4.6.tar.xz cd libtool-2.4.6 ./configure --program-prefix=g make && sudo make install
-
python3のインストール(mpvのコンパイルに用いる)
mpvは、バージョン0.33.0から、python2.xのサポートを止めた。よってpython3.xをインストールする必要がある。
このpythonは、起動ディスク直下のライブラリにpython.frameworkとしてインストールされ、呼び出しはpython3となる。
インストーラーパッケージの処理が終わった後、Finderで、
/Applications/Python 3.10
フォルダが開く。ここでフォルダ内のInstall Certificates.command
をダブルクリックして実行すること。なお、2022.05.20時点でのバージョンは3.10.4である。
-
libpngのコンパイル&インストール
cd ${SRC} curl -LO http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz cd ${CMPL} tar xf ${SRC}/libpng-1.6.37.tar.xz cd libpng-1.6.37 ./configure --prefix=${TARGET} --disable-shared make && make install
-
freetypeの仮コンパイル&インストール
freetypeとharfbuzzは、お互いが依存しあっているので、まず、harfbuzzなしでfreetypeをビルドする。
cd ${SRC} curl -LO https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.xz cd ${CMPL} tar xf ${SRC}/freetype-2.12.1.tar.xz cd freetype-2.12.1 ./configure --prefix=${TARGET} --disable-shared --with-harfbuzz=no make && make install
-
harfBuzzのコンパイル&インストール
freetypeとharfbuzzは、お互いが依存しあっているので、次に、harfbuzzをfreetypeを含めてビルドする。
cd ${SRC} curl -LO https://github.com/harfbuzz/harfbuzz/releases/download/4.2.1/harfbuzz-4.2.1.tar.xz cd ${CMPL} tar xf ${SRC}/harfbuzz-4.2.1.tar.xz cd harfbuzz-4.2.1 ./configure --prefix=${TARGET} --disable-shared --enable-static make && make install
-
freetypeのコンパイル&インストール
freetypeとharfbuzzは、お互いが依存しあっているので、今度は、harfbuzzありでfreetypeをビルドする。
cd ${CMPL}/freetype-2.12.1 ./configure --prefix=${TARGET} --disable-shared make clean make && make install
-
expatのコンパイル&インストール
cd ${SRC} curl -LO https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.xz cd ${CMPL} tar xf ${SRC}/expat-2.4.8.tar.xz cd expat-2.4.8 ./configure --prefix=${TARGET} --disable-shared --enable-static make && make install
-
libuuidのコンパイル&インストール
fontconfigのコンパイルに必要である。
cd ${SRC} curl -LO http://sourceforge.net/projects/libuuid/files/libuuid-1.0.3.tar.gz cd ${CMPL} tar xf ${SRC}/libuuid-1.0.3.tar.gz cd libuuid-1.0.3 ./configure --prefix=${TARGET} --disable-shared --enable-static make && make install mv ${TARGET}/include/uuid/uuid.h ${TARGET}/include/uuid/uuid.h.bak
-
fontconfigのコンパイル&インストール
freetypeとexpatはfontconfigの依存ライブラリである。
cd ${SRC} curl -LO https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.14.0.tar.xz cd ${CMPL} tar xf ${SRC}/fontconfig-2.14.0.tar.xz cd fontconfig-2.14.0 ./configure --prefix=${TARGET} --disable-shared --disable-docs --enable-static --with-add-fonts=/Library/Fonts,~/Library/Fonts make && make install
-
fribidiのコンパイル&インストール
新規インストールの場合
cd ${CMPL} git clone https://github.com/fribidi/fribidi.git cd fribidi ./autogen.sh ./configure --prefix=${TARGET} --disable-shared --enable-static make && make install
更新インストールの場合
cd ${CMPL}/fribidi git pull ./autogen.sh ./configure --prefix=${TARGET} --disable-shared --enable-static make clean make && make install
-
libassのコンパイル&インストール
fontconfigとFriBidiは、libassの依存ライブラリである。
cd ${SRC} curl -LO https://github.com/libass/libass/releases/download/0.16.0/libass-0.16.0.tar.xz cd ${CMPL} tar xf ${SRC}/libass-0.16.0.tar.xz cd libass-0.16.0 ./configure --prefix=${TARGET} --disable-shared make && make install
-
libblurayのコンパイル&インストール
cd ${SRC} curl -LO https://download.videolan.org/pub/videolan/libbluray/1.3.1/libbluray-1.3.1.tar.bz2 cd ${CMPL} tar xf ${SRC}/libbluray-1.3.1.tar.bz2 cd libbluray-1.3.1 ./configure --prefix=${TARGET} --without-libxml2 --disable-shared --disable-bdjava-jar make && make install
-
ffmpegのコンパイル&インストール
新規インストールの場合
cd ${CMPL} git clone git://source.ffmpeg.org/ffmpeg.git cd ffmpeg
更新インストールの場合
cd ${CMPL}/ffmpeg git pull make clean
configureとmake(共通)
./configure \ --prefix=${TARGET} \ --pkg-config-flags=--static \ --enable-libass \ --enable-libbluray \ --disable-programs \ --disable-doc make && make install
-
luaスクリプト言語のコンパイルとインストール
(現行バージョンではなく、5.2.xを用いる)
luaはmpvビルドに必須ではない。youtube-dlと連携して、youtubeストリーミング動画を再生するために導入する。cd ${SRC} curl -LO https://www.lua.org/ftp/lua-5.2.4.tar.gz cd ${CMPL} tar xf ${SRC}/lua-5.2.4.tar.gz cd lua-5.2.4 make macosx install INSTALL_TOP=${TARGET}
mpvがluaパッケージを見つけられるようにlua.pcファイルを作成する。
cat >${TARGET}/lib/pkgconfig/lua.pc <<EOF prefix=/Volumes/mpv_compile exec_prefix=\${prefix} libdir=\${prefix}/lib/ includedir=\${prefix}/include Name: lua Description: lua Requires: Version: 5.2.4 Libs: -L\${libdir} -llua Cflags: -I\${includedir} EOF
-
luaだけでなくluaJITも必要である。よってluaJITをコンパイル&インストールする。
cd ${SRC} curl -LO http://luajit.org/download/LuaJIT-2.0.5.tar.gz cd ${CMPL} tar xf ${SRC}/LuaJIT-2.0.5.tar.gz cd LuaJIT-2.0.5 make PREFIX=${TARGET} make install PREFIX=${TARGET}
ダイナミックローダブルライブラリの削除
rm -v ${TARGET}/lib/libluajit*dylib
-
mpvのコンパイルとインストール
git headまたは、安定版リリースを用いる。安定版リリース Ver.0.34.1
cd ${SRC} curl -LO https://github.com/mpv-player/mpv/archive/refs/tags/v0.34.1.tar.gz cd ${CMPL} tar xf ${SRC}/v0.34.1.tar.gz cd mpv-0.34.1 ./bootstrap.py
git head
新規インストールの場合
cd ${CMPL} git clone https://github.com/mpv-player/mpv.git cd mpv ./bootstrap.py
更新インストールの場合
cd ${CMPL}/mpv git pull rm waf ./bootstrap.py ./waf clean
configureオプション(共通)
export PKG_CONFIG=/usr/local/bin/pkg-config sed '/ctx.find_program.ar/d' -i wscript ./waf configure \ --prefix=${TARGET} \ --disable-debug-build \ --disable-manpage-build \ CC=/usr/bin/gcc AR=/usr/bin/ar
ビルドとインストール(共通)
./waf build ./waf install
macOSアプリケーションバンドルパッケージの作成
TOOLS/osxbundle.py build/mpv
出来上がったコマンドライン版のmpvは
${TARGET}/bin
に、GUI版のmpvは${TARGET}/compile/mpv/build
にある。筆者の場合、コマンドライン版は/usr/local/bin
に置いている。注意:
macOS 10.14 Mojave以降でアプリケーションバンドルを起動しようとすると、次のようなダイアログが出る。これを拒否せずに、システム環境設定のアクセシビリティ項目で許可する必要がある。
以上
参考サイト
この投稿へのトラックバック
トラックバックはありません。
- トラックバック URL
この投稿へのコメント