0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ffmpeg4.3.1をUbuntuでWindows用にビルドする

Posted at

忘れないようにメモします。

私はとりあえず動けばOKという感じでビルドするので警告とか無視していきます。
この記事の手順でビルドして問題が起きても私は責任を負いません。自己責任でお願いします。

専用のツールが用意されているのでとっても楽です。

Ubuntuの設定

今回はUbuntu 20.4 jaを使用しました。
仮想化ソフトはVMware Workstation 15 Playerを使用しました。
WSLでも動きます。

ツールのダウンロード

ディレクトリはhomeディレクトリ以下ならどこでもいいです。

git clone https://github.com/rdp/ffmpeg-windows-build-helpers.git
cd ffmpeg-windows-build-helpers

必要パッケージのダウンロード

とりあえず実行します。

./cross_compile_ffmpeg.sh

するとログの中にsudo apt install 〇〇みたいなコマンドが出るのでそれをコピーして実行します。

sudo apt-get install subversion ragel curl texinfo g++ bison flex cvs yasm automake libtool autoconf gcc cmake git make pkg-config zlib1g-dev mercurial unzip pax nasm gperf autogen bzip2 autoconf-archive p7zip-full clang python3 python3-pip python3-setuptools python3-wheel ninja-build -y

Ubuntu 18.04なら

sudo apt install python3-distutils -y

Ubuntu 20.04なら

sudo apt install python-is-python3 -y

が必要です。

次にその他に必要なものをインストールします。

sudo apt install python3-pip -y
sudo pip3 install ninja meson

ffmpegのビルド

./cross_compile_ffmpeg.sh --build-ffmpeg-shared=y --build-intel-qsv=y --build-amd-amf=y --ffmpeg-git-checkout-version=n4.3.1 --enable-gpl=n

私はこんな感じで実行しました。
数時間かかります。
ターゲットには32bit、64bit一緒にビルド、もしくは片方だけを選びましょう。

dllがほしかったので--build-ffmpeg-shared=yでdllを生成するようにしました。不要であれば--build-ffmpeg-static=yです。

--build-intel-qsv=y --build-amd-amf=y
ここでIntel QSV、AMD amfをオプションで有効にします。
NVENC、NVDECは自動で有効になるようです。

--enable-gpl=nにするとlibx264が無効になります。--enable-gpl=yだとlibx264がインストールされます。
どうやら標準でOpenH264が使われるようです。

--ffmpeg-git-checkout-version=n4.3.1でffmpegのバージョンを指定します。指定しなかったら最新のファイルを落としてくるようです。
こちらのツールは最新版用に作られているようなので、最新版を指定しないとエラーが出る可能性があります。

その他詳しい設定についてはshファイルの中を覗くのがいいかもしれません。
詳細に変更したいなら直接書き換えたほうがいいと思います。

ビルド完了ログ

Done! You will find 32-bit shared binaries in /home/kusaanko/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git_lgpl_n4.3.1_shared/bin

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=ja_JP.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (906E9),ASM,AES-NI)

Scanning the drive:
9 folders, 145 files, 82126029 bytes (79 MiB)

Creating archive: /home/kusaanko/ffmpeg-windows-build-helpers/sandbox/redist/ffmpeg-N-98189-g6b6b9e593d-win32-shared.7z

Items to compress: 154

                                       
Files read from disk: 145
Archive size: 27850375 bytes (27 MiB)
Everything is Ok

完成したファイルの場所

私の場合だとここにありました。
ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_lgpl_n4.3.1_shared/bin/
最後のログに出てるのでそこを読めばわかります。

エラー

ERROR: libaribb24 requires version higher than 1.0.3 or --enable-gpl.

libaribb24の最新バージョンが1.0.3なのに1.0.3より新しいバージョンを要求されます。
LGPLでのビルドを諦めるか、同梱を諦めます。
同梱を諦めるコマンドがこちら

sed -i -e 's/--enable-libaribb24 //' ./cross_compile_ffmpeg.sh
sed -i -e 's/--enable-libx264 --enable-libx265/--enable-libx264 --enable-libx265 --enable-libaribb24/' ./cross_compile_ffmpeg.sh

最後に

ffmpegを使うときはライセンスに気をつけましょう。ライセンス料とか色々考えなければなりません。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?