TagReplc で利用可能なオープンソースソフトウェアのビルドについて
TagReplc で利用するための fdkaac と FFmpeg と opusenc のビルド例を記します。
あくまで筆者が試して TagReplc での動作が一応確認できた例であり、最も効率的で最適な方法ではありません。
ビルドと動作確認した環境は Windows 11 Home です。
いずれも MSYS2 UCRT64 環境下でのビルドですので、MSYS2 がインストールされていることが必要です。
【MSYS2 のインストール】
MSYS2("minimal system 2") は Microsoft Windows 向けのソフトウェアの配布・構築環境です。
MSYS2 のページ の Installation の指示に従ってインストールしてください。
インストール後に MSYS2 のターミナルから pacman (package manager) コマンドによってパッケージの更新を行ってください。
pacman -Syu
を入力してください。
処理後、MSYS2 のターミナルは閉じられます。
【参考】MSYS2 の解説ページ
【fdkaac のビルド】
[スタート]⇒[すべて]⇒[MSYS2]⇒[MSYS2 UCRT64]で UCRT64 環境のターミナルを開いてください。
下記を1行ずつコピーして、MSYS2 UCRT64 のターミナルウィンドウの入力プロンプト($)のあとに貼り付けて実行してください。
(なお、1行目実行中の問い合わせ "Enter a selection (default=all):" に対しては enter キー、":: Proceed with installation? [Y/n]" に対しては 'y' で応答してください。)
pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-toolchain autoconf automake-wrapper git make libtool base-devel
cd ~
git clone https://github.com/mstorsjo/fdk-aac
cd ~/fdk-aac
autoreconf -i -f
./configure --prefix=/ucrt64 --disable-shared
make -j$(nproc)
make install
cd ~
git clone https://github.com/nu774/fdkaac.git
cd ~/fdkaac
autoreconf -i
export PKG_CONFIG_PATH="/ucrt64/lib/pkgconfig:$PKG_CONFIG_PATH"
./configure --prefix=/ucrt64
make -j$(nproc)
make install
完了後に
ls -l fdkaac.exe
でファイルサイズを確認してください。
ビルドされた "fdkaac.exe" は Windows の File Explorer では "C:\msys64\home\(username)\fdkaac\fdkaac.exe" にありますので、適当なフォルダにコピーしてください。
なお、上記でビルドされた "fdkaac.exe" には libfdk-aac が静的リンクされていますので、"Fraunhofer FDK AAC license" により "fdkaac.exe" の配布は禁じられています。
【ffmpeg.exe のビルド】
【1】LGPL バージョンのビルド
- TagReplc.exe から利用するためにライセンスが GPL になることは避けて LGPL (Lesser General Public License) になるようにします
- ffmpegに組み込むライブラリはできるだけ pacman -S でパッケージで取得するようにしています
- pacman -S で取得できるパッケージは MSYS2 の Package Search で検索できます
- 本例では libvorbis には評価の高い aoTuV (AOyumi TUned Vorbis) のエンコーダーをインストールする設定にしています
- 本家の Xiph.Org の libvorbis を選択する場合は "pacman -S mingw-w64-ucrt-x86_64-libvorbis" を指定すれば下記の git ~ make を省略できます
- 動画のエンコード機能は下記の pacman -S や ./configure でほとんど指定していませんが、.webm や .ogg のお試しで使用されることがある libvpx や libtheora を指定しています
[スタート]⇒[すべて]⇒[MSYS2]⇒[MSYS2 UCRT64]で UCRT64 環境のターミナルを開いてください。
下記を1行ずつコピーして、MSYS2 UCRT64 のターミナルウィンドウの入力プロンプト($)のあとに貼り付けて実行してください。
pacman -S base-devel mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libunistring mingw-w64-ucrt-x86_64-perl mingw-w64-ucrt-x86_64-SDL2 nasm yasm wget git unzip p7zip make cmake tar automake autoconf libtool pkg-config mercurial
pacman -S mingw-w64-ucrt-x86_64-lame mingw-w64-ucrt-x86_64-opus mingw-w64-ucrt-x86_64-libvpx mingw-w64-ucrt-x86_64-libtheora mingw-w64-ucrt-x86_64-libogg mingw-w64-ucrt-x86_64-wavpack mingw-w64-ucrt-x86_64-openjpeg2
cd ~
git clone https://github.com/AO-Yumi/vorbis_aotuv.git
cd ~/vorbis_aotuv
./configure --prefix=/ucrt64 --disable-shared
make -j$(nproc)
make install
cd ~
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar -jxvf ffmpeg-snapshot.tar.bz2
cd ~/ffmpeg
./configure --disable-gpl --disable-version3 --disable-nonfree --enable-ffmpeg --disable-debug --disable-ffplay --disable-ffprobe --disable-doc --enable-libmp3lame --disable-libfdk-aac --enable-libopus --enable-libvorbis --enable-libvpx --enable-libtheora --enable-libopenjpeg --extra-ldflags="-L/ucrt64/lib -static" --optflags="-O2 -finline-functions" --disable-shared --pkg-config-flags="--static" --enable-small --enable-runtime-cpudetect --enable-static --extra-libs=-static --extra-cflags=--static --arch=x86_64
make -j$(nproc)
make install
cd ffmpeg の次の ./configure の実行時の表示の最後に
License: LGPL version 2.1 or later
と表示されていることを確認してください。
完了後に
ls -l ffmpeg.exe
でファイルサイズを確認してください。
また、
ldd ffmpeg.exe
で表示される .dll が全て => /c/WINDOWS/.... となっておりスタティックビルドされていることを確認してください。
ビルドされた "ffmpeg.exe" は Windows の File Explorer では "C:\msys64\home\(username)\ffmpeg\ffmpeg.exe" にありますので、適当なフォルダにコピーしてください。
Windows のコマンドプロンプトで "ffmpeg -L" と入力すると "ffmpeg is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version." などのメッセージが表示されるはずです。
【2】Fraunhofer FDK AAC を含めたビルド
- 【1】を実施してビルドされた "ffmpeg.exe" を上書きする例です
- 【fdkaac のビルド】を実施済みの場合は libfdk-aac は既に生成されているはずなので、下記の "pacman -S mingw-w64-ucrt-x86_64-fdk-aac" は不要です
- 【1】の ./configure の --disable-nonfree と --disable-libfdk-aac を --enable-... に変更しています
下記を1行ずつコピーして、MSYS2 UCRT64 のターミナルウィンドウの入力プロンプト($)のあとに貼り付けて実行してください。
cd ~
pacman -S mingw-w64-ucrt-x86_64-fdk-aac
cd ~/ffmpeg
./configure --disable-gpl --disable-version3 --enable-nonfree --enable-ffmpeg --disable-debug --disable-ffplay --disable-ffprobe --disable-doc --enable-libmp3lame --enable-libfdk-aac --enable-libopus --enable-libvorbis --enable-libvpx --enable-libtheora --enable-libopenjpeg --extra-ldflags="-L/ucrt64/lib -static" --optflags="-O2 -finline-functions" --disable-shared --pkg-config-flags="--static" --enable-small --enable-runtime-cpudetect --enable-static --extra-libs=-static --extra-cflags=--static --arch=x86_64
make -j$(nproc)
make install
cd ffmpeg の次の ./configure の実行時の表示の最後に
License: nonfree and unredistributable
と表示されていることを確認してください。
ビルドされた ffmpeg.exe は Windows の File Explorer では "C:\msys64\home\(username)\ffmpeg\ffmpeg.exe" にありますので、適当なフォルダにコピーしてください。
Windows のコマンドプロンプトで "ffmpeg -L" と入力すると一番下に "This version of ffmpeg has nonfree parts compiled in. Therefore it is not legally redistributable." と表示されるはずです。
libfdk-aac を含めてビルドしたため "License: LGPL version 2.1 or later" ではなくなり、バイナリの再配布は禁止されますが、FFmpeg の License についてのコメントの最終行によれば libfdk-aac は "To the best of our knowledge, they are compatible with the LGPL." とのことですので、本例でビルドされた ffmpeg.exe も再配布禁止を除けば LGPL 相当とみなされるように思われます。
【opusenc.exe のビルド】
- opusenc.exe のバイナリコードは、TagReplc取扱説明書の表6 にリンクされているURLからダウンロード可能ですが、MSYS2 のパッケージ版をインストールすることも可能です。
- 下記は MSYS2 でパッケージから pacman でインストールした例ですが、スタティックビルドではないので opusenc.exe 実行時にはいくつかの動的リンクライブラリ(DLL)を必要とします。
- 現時点では libopus 1.5.2 を用いた opusenc.exe をインストールできます。
[スタート]⇒[すべて]⇒[MSYS2]⇒[MSYS2 UCRT64]で UCRT64 環境のターミナルを開き、下記の1行をコピーして MSYS2 UCRT64 のターミナルウィンドウの入力プロンプト($)のあとに貼り付けて実行してください。
pacman -S mingw-w64-ucrt-x86_64-opus-tools
完了後に
cd /ucrt64/bin
ls -l opus*.exe
とすると /ucrt64/bin ディレクトリに opusdec.exe, opusenc.exe, opusinfo.exe の3つの実行ファイルが作成されていることが確認できます。
実行ファイル "opusenc.exe" の Dynamic Dependencies を
ldd opusenc.exe
で確認すると /ucrt64/bin ディレクトリ内については5つのDLL(libopusenc-0.dll, libopus-0.dll, libFLAC.dll, libogg-0.dll, libwinpthread-1.dll)との依存関係が表示されます。
TagReplc.exe で本例でインストールされた "opusenc.exe" を使うためには、
- TagReplc.exe のプログラムフォルダにある設定ファイル"TagReplc.ini" の "OpusEnc_Exe" という名前(キー)のパラメタ(エントリ)の値として、opusenc.exe のパス(フルパス)を記載します。
インストールされた "opusenc.exe" は Windows の File Explorer では "C:\msys64\ucrt64\bin\opusenc.exe" にありますので、適当なフォルダにコピーした場合はそのフォルダでのパスを、コピーしない場合は
(例)OpusEnc_Exe=C:\msys64\ucrt64\bin\opusenc.exe
のように記載します。
- 本例でインストールされた "opusenc.exe"(64bit)の実行の際には libopus-0.dll, libopusenc-0.dll ,libFLAC.dll (いずれも64bit)を必要としますので、これらのDLLをアクセス可能なフォルダに配置します。
"TagReplc.ini" の "EnvVarPATH" エントリにセミコロン(;)で区切ってパスを追記すればアクセスできます。
(例)EnvVarPATH=C:\user\app\qaac\aas64_dll;C:\msys64\ucrt64\bin
- ちなみに、Windows環境で opusenc.exe を実行する際に必要な .dll は、Visual Studio Developer Command Prompt などで
dumpbin.exe /DEPENDENTS "C:\msys64\ucrt64\bin\opusenc.exe"
と入力すると、libopus-0.dll, libopusenc-0.dll ,libFLAC.dll のほかに api-ms-win-crt-*-l1-1-0.dll に依存してることが確認できます。
- "api-ms-win-crt-*-l1-1-0.dll" は「Microsoft C および C++ (MSVC) ランタイム ライブラリ」に関連するDLLです。インストールされていない可能性がある場合は「Visual C++再頒布可能パッケージ」のインストールを検討してみてください。