HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

[UPDATE] 2023/10/15

【2023年】Windowsで高音質な fdk-aacを有効にした FFmpegをビルドする方法 【2023年】Windowsで高音質な fdk-aacを有効にした FFmpegをビルドする方法

(Windowsで Fraunhofer FDK AACが使える FFmpegを自分でコンパイルしてインストールする方法)

Tags: [Raspberry Pi], [電子工作]




● Raspberry Piで高音質な fdk-aacを有効にした動画処理アプリ FFmpegをビルドする方法


2023/01/15
【2023年】Raspberry Piで高音質な fdk-aacを有効にした FFmpegをビルドする方法
【2023年】Raspberry Piで高音質な fdk-aacを有効にした FFmpegをビルドする方法

  ラズパイで Fraunhofer FDK AACが使える FFmpegを自分でコンパイルしてインストールする方法


● FFmpegをビルドする方法を動画で解説

【2023年】Windows用の FDK AACを有効にした FFmpegをビルドする方法



● 2023/10/21 FFmpegの簡単ビルド スクリプトを更新しました

 下記でプルリクをしています。
 下記のプルリクが速攻で承認されて本家に取り込まれました!!

Improve extra script for WSL can Build specify FFmpeg versions #716

・ FFmpeg version
 FFmpeg 4.4.4
 FFmpeg 5.0.3
 FFmpeg 5.1.3
 FFmpeg 6.0
 FFmpeg 最新

・ Build Confirmed 2023/10/21
 Windows 11 22H2 WSL Ubuntu 22.04
 Windows 10 22H2 WSL Ubuntu 20.04
# You can build each FFmpeg verisons following
#  The build time from the 2nd time onwards is about 10 minutes
./extra/make.sh
./extra/make.sh n5.0.3
./extra/make.sh n5.1.3
./extra/make.sh n6.0
./extra/make.sh master


● 2023/10/21 decklink-headers NotABug.org Git server is downの回避パッチ

 下記でプルリクをしています。
 下記のプルリクが速攻で承認されて本家に取り込まれました!!

If NotABug.org server is down Change to use GitLab.com . for decklink-headers #715

 Blackmagic Designの製品用の SDKの decklink-headersの NotABug.org Gitサーバがダウンしているとエラーが発生してビルドできないのでフェイルセーフとして GitLab.comから取得する様にしました。

NotABug.org - decklink-headers

GitLab.com - decklink-headers



● 2023/10/15 FFmpegの簡単ビルド スクリプトを更新しました

 スクリプトの更新は下記でプルリクをしています。
 下記のプルリクが速攻で承認されて本家に取り込まれました!!

Update extra Script for WSL Ubuntu to More Easily build FFmpeg 4.4.4 #714
・ Update items
* Updated from FFmpeg 4.4.3 to 4.4.4
* fix no member named 'compressed_ten_bit_format'
  libavcodec/libsvtav1.c:124:51: error: 'EbSvtAv1EncConfiguration' has no member named 'compressed_ten_bit_format'
  change fix method to cherry pick
* Disable libaribcaption --enable-libaribcaption
  Because FFmpeg 4.4.x doesn't have this option
* fix ERROR: nvenc requested but not found
  specify version nv-codec-headers n12.0.16.1

・ Build Confirmed 2023/10/16
* Windows 11 22H2 WSL Ubuntu 22.04
* Windows 10 22H2 WSL Ubuntu 20.04

Unknown option "--enable-libaribcaption".

lavc/libaribcaption.c: add ARIB caption decoder using libaribcaption


n4.4.4 configure#L221

  --enable-libaribb24      enable ARIB text and caption decoding via libaribb24 [no]

master configure#L217

  --enable-libaribb24      enable ARIB text and caption decoding via libaribb24 [no]
  --enable-libaribcaption  enable ARIB text and caption decoding via libaribcaption [no]
ERROR: nvenc requested but not found

 n12.1.14.x系は上記のエラーが出るので
nv-codec-headers n12.0.16.1

 を使用する。

sed -i -e "s/nv-codec-headers\.git$/nv-codec-headers.git nv-codec-headers_git n12.0.16.1/g" cross_compile_ffmpeg.sh

● ffmpeg.exe -version
> \\wsl.localhost\Ubuntu\home\user\ffmpeg-windows-build-helpers\sandbox\win64\ffmpeg_git_with_fdk_aac_n4.4.4\ffmpeg.exe -version
ffmpeg version n4.4.4-ffmpeg-windows-build-helpers Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 10.2.0 (GCC)
configuration: --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=ffmpeg-windows-build-helpers --enable-version3 --disable-debug --disable-w32threads --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --enable-libcaca --enable-gray --enable-fontconfig --enable-gmp --enable-libass --enable-libbluray --enable-libbs2b --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libwebp --enable-libzimg --enable-libzvbi --enable-libmysofa --enable-libopenjpeg --enable-libopenh264 --enable-libvmaf --enable-libsrt --enable-libxml2 --enable-opengl --enable-libdav1d --enable-cuda-llvm --enable-gnutls --enable-libsvtav1 --enable-libvpx --enable-libaom --enable-nvenc --enable-nvdec --extra-libs=-lharfbuzz --extra-libs=-lm --extra-libs=-lshlwapi --extra-libs=-lmpg123 --extra-libs=-lpthread --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCACA_STATIC --enable-amf --enable-libmfx --enable-gpl --enable-frei0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-avisynth --enable-libaribb24 --enable-libxvid --enable-libdavs2 --enable-libxavs2 --enable-libxavs --extra-cflags='-mtune=generic' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --disable-libdav1d --enable-nonfree --enable-libfdk-aac --enable-decklink
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100
● FFmpegの実行ファイルを Windowsの C:\ffmpeg_tmpディレクトリにコピー

ls -l ./sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.4/ff*.exe
ls -l ./sandbox/win64/x264/x*.exe
ls -l ./sandbox/win64/x265/8bit/x*.exe

mkdir /mnt/c/ffmpeg_tmp/
cp ./sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.4/ff*.exe /mnt/c/ffmpeg_tmp/
cp ./sandbox/win64/x264/x*.exe /mnt/c/ffmpeg_tmp/
cp ./sandbox/win64/x265/8bit/x*.exe /mnt/c/ffmpeg_tmp/
rm /mnt/c/ffmpeg_tmp/ff*_g.exe

ls -l /mnt/c/ffmpeg_tmp/

$ ls -l /mnt/c/ffmpeg_tmp/
-rwxrwxrwx 1 user user 107770368 Oct 16 14:41 ffmpeg.exe
-rwxrwxrwx 1 user user 107632128 Oct 16 14:41 ffplay.exe
-rwxrwxrwx 1 user user 107668480 Oct 16 14:41 ffprobe.exe
-rwxrwxrwx 1 user user   2503168 Oct 16 14:41 x264.exe
-rwxrwxrwx 1 user user  25500368 Oct 16 14:41 x265.exe


● 2023/05/05現在、下記のエラーが出ます

 「compressed_ten_bit_formatが無え!」のエラー

libavcodec/libsvtav1.c: In function 'alloc_buffer':
libavcodec/libsvtav1.c:124:51: error: 'EbSvtAv1EncConfiguration' has no member named 'compressed_ten_bit_format'
  124 |         (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
      |                                                   ^~
CC      libavcodec/libvo-amrwbenc.o
make: *** [ffbuild/common.mak:67: libavcodec/libsvtav1.o] Error 1
make: *** Waiting for unfinished jobs....

 SVT-AV1のライブラリの最近の下記のアップデートが原因です。
 「compressed_ten_bit_formatを削除したお! (^ω^)」

 暫くすれば関連のチームが気が付いて対応すると思うので解決すると思います。
SVT-AV1
2023-04-26 15:11:56 -0700: Hassene Tmar - ea296ef3
    Cleanup deprecated compressed_ten_bit_format signal << これ!
2023-04-25 16:47:10 -0700: Hassene Tmar - 7247bdda
    Bump rev to v1.5.0
2023-04-25 16:46:19 -0700: Hassene Tmar - e32243c0
    Update CHANGELOG.md to reflect changes between v1.4.1 and v1.5.0

https://gitlab.com/AOMediaCodec/SVT-AV1/-/commit/ea296ef350714fb6f105b420fb0bc321d9997ffd

https://gitlab.com/AOMediaCodec/SVT-AV1/-/tree/v1.4.1

 待てない場合は下記の方法でライブラリのバージョンを古い物を指定します。

 SVT-AV1ライブラリに v1.4.1を指定する方法で対応できたお(^ω^)

cross_compile_ffmpeg.sh#L1612

cross_compile_ffmpeg.sh
build_svt-hevc() {
  do_git_checkout https://gitlab.com/AOMediaCodec/SVT-AV1.git
 ↓
  do_git_checkout https://gitlab.com/AOMediaCodec/SVT-AV1.git SVT-AV1_git v1.4.1
 sedコマンドでサクッと楽に書き換える方法
sed -i -e "s/SVT-AV1\.git/SVT-AV1.git SVT-AV1_git v1.4.1/g" cross_compile_ffmpeg.sh

 下記の SVT-AV1ライブラリの残骸を消します
rm -rf sandbox/win64/SVT-AV1_git

# Windows 11の場合は下記を再度実行します
./extra/make.sh

# Windows 10の場合は下記を再度実行します
./extra/make_win10.sh

 2023/10/15 追記:下記の対応を取り込めば v1.5.0を使えます

avcodec/libsvtav1: remove compressed_ten_bit_format and simplify allo…
 で、2022/11/18に FFmpeg n6.0系には対応がありました。
 ("no effect and can be removed"で「影響無いし削除できる」、と言っている)
libavcodec/libsvtav1.c
static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
{
    const size_t luma_size = config->source_width * config->source_height *
        (config->encoder_bit_depth > 8 ? 2 : 1);

    EbSvtIOFormat *in_data;

    svt_enc->raw_size = luma_size * 3 / 2;

    // allocate buffer for in and out
# https://github.com/FFmpeg/FFmpeg/commit/031f1561cd286596cdb374da32f8aa816ce3b135
# avcodec/libsvtav1: remove compressed_ten_bit_format and simplify allo…
 同じ対応を FFmpeg 4.x系や FFmpeg 5.x系に行なう事で解決しました。
git cherry-pick 031f156

sed -i -e "s/  cd \$output_dir/  cd \$output_dir\n  git cherry-pick 031f156/g" cross_compile_ffmpeg.sh


● Windowsで高音質な fdk-aacを有効にした動画処理アプリ FFmpegをコンパイルする方法

 Windowsで Fraunhofer FDK AACが使える FFmpegを自分でコンパイルしてインストールする方法

FFmpeg公式のビルド方法

FFmpeg Cross Compiling for Windows

 FFmpeg公式のビルド方法が有りますが、ffmpeg-windows-build-helpersを使います。

rdp / ffmpeg-windows-build-helpers

 Windowsの WSL環境(Windows Subsystem for Linux)と ffmpeg-windows-build-helpersを使用する事で超簡単に Fraunhofer FDK AACが使える FFmpegをビルドできます。

 WSL環境は Ubuntuを使用します。
 WSL環境の Debianは Ubuntuと比較すると駄目駄目です。

 Fraunhofer FDK AACは高音質で有名です。
 (と言うか、FFmpegに内蔵の AACエンコーダが腐っている)

 バイナリが配布されている通常の FFmpegに内蔵の AACエンコーダ(Native FFmpeg AAC Encoder)よりも段違いに音が良いです。

プラットフォーム - Fraunhofer IIS FDK AAC

FFmpeg Encode/AAC


● apt-getでインストールできる FFmpegで使用できる AACエンコーダは低音質

$ sudo apt-get -y install ffmpeg

$ ffmpeg -version

$ sudo apt-get -y purge ffmpeg


● Windows用の FFmpegをビルドする

● Install WSL and Ubuntu
rem Install WSL and Ubuntu
wsl --install

rem Download & Install Ubuntu 22.04 LTS
wsl --install -d Ubuntu-22.04

rem Download & Install Ubuntu 20.04 LTS
wsl --install -d Ubuntu-20.04

rem Uninstall
wsl --unregister XXXX

● Ubuntu 20.04
# Windows 10 22H2
$ uname -a
Linux WIN10 4.4.0-19041-Microsoft #2311-Microsoft Tue Nov 08 17:09:00 PST 2022 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -rs
20.04

● Ubuntu 22.04
# Windows 11 22H2
$ uname -a
Linux WIN11 5.15.79.1-Microsoft-STANDARD-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -rs
22.04


● ffmpeg-windows-build-helpers FREE WING改造版を使う場合の手順

 オリジナル版はそのままではビルドができない問題が有るのでそれを全自動で解決しビルドの作業手順を大幅に簡略化した FREE WING改造版を作りました。

 現在はビルドするにはいくつかのパッチが必要で、cross_compile_ffmpeg.shのスクリプトも数回実行する必要が有ります。
 これらの手順は初心者にとっては難しく感じます。
 私は、WSL Ubuntu用に全自動でパッチとビルドを行うスクリプトを追加しました。
 このスクリプトを使う事で1回スクリプトを実行するだけで FFmegのバイナリをビルドできます。

FREE WING改造版
 改造部分は extraディレクトリのスクリプトとなります。

Add extra Script for WSL Ubuntu to More Easily build #668
 本家にもプルリクをしました。
 1/27 マージされました。

Linuxの種類とバージョン制限事項Windowsのバージョン
Ubuntu 22.04(推奨)tesseractを無効にする必要が有るWindows 11
Ubuntu 20.04tesseractを無効にする必要が有るWindows 11
Ubuntu 20.04(推奨)libsndfileが失敗するので bdwgcをビルドする
gitの証明書のチェックを無効にする
Windows 10
Ubuntu 18.04ビルド未確認Windows 10/ 11
Debian 11.6tesseractを無効にする必要が有るWindows 11
Debian 9.5ビルド未確認Windows 10
 ※ Windows 11の Ubuntu 20.04以降が他と比べると楽です。

● FREE WING改造版は WSLの Ubuntuだけに対応しています(Debianには原則非対応)
# ffmpeg-windows-build-helpers FREE WING改造版をダウンロードする
cd
git clone https://github.com/FREEWING-JP/ffmpeg-windows-build-helpers
cd ffmpeg-windows-build-helpers

# オリジナル版に必要なパッチや各種初期設定を行ない FDK-AACを有効にした FFmpeg 4.4.3をビルドします
 ※ 2023年 1月現在 4.4.x系は 4.4.3が最新

 Win64 (64-bit only)を全自動でビルドします。
 (32-bit版が必要な場合は ./extra/build.shを編集します)

# Windows 11の場合は下記を実行します
./extra/make.sh

# Windows 10の場合は下記を実行します
./extra/make_win10.sh


# ビルドが完了するまで数時間待つ
 (マシンスペックに依存で1~数時間掛かります)
CPUWSL LinuxBuild Time
Ryzen 5 PRO 3400GEWindows 11 WSL Ubuntu 22.0490 min
Ryzen 5 PRO 3400GEWindows 11 WSL Ubuntu 20.0475 min
Ryzen 7 PRO 4750GWindows 10 WSL Ubuntu 20.04111 min
Core i5-8259UWindows 10 WSL Ubuntu 20.04172 min


●下記のビルドの種類の選択は無くしました

 必要な場合は ./extra/build.shを編集します。

# 10~20分程度で下記の表示が出る

     ##################### Welcome ######################
  Welcome to the ffmpeg cross-compile builder-helper script.
 ...
What version of MinGW-w64 would you like to build or update?
  1. Both Win32 and Win64
  2. Win32 (32-bit only)
  3. Win64 (64-bit only)
  4. Local native
  5. Exit
{2]Input your choice [1-5]: 3
# Win64 (64-bit only)の場合は 3を入力する。


●ビルドが成功!

 --enable-libfdk-aacが正しく存在している!

Done! You will find 64-bit static non-redistributable binaries in /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3
Thu Jan 19 14:17:28 JST 2023
searching for all local exe's (some may not have been built this round, NB)...
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffmpeg.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_n4.2.8/ffmpeg.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3/ffmpeg.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_n4.2.8/ffmpeg_g.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3/ffmpeg_g.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffplay.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_n4.2.8/ffplay.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3/ffplay.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/share/doc/ffmpeg
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/share/ffmpeg
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/x264.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/x264_all_bitdepth/x264.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/x265.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/x265_all_bitdepth/8bit/x265.exe
$ ls -l ./sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3/ffmpeg_g.exe
-rwxr-xr-x 1 user user 256545438 Jan 19 14:17 ./sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3/ffmpeg_g.exe

./ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/
./ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/x265.exe
./ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffprobe.exe
./ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffmpeg.exe
./ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffplay.exe
./ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/x264.exe
$ ./sandbox/win64/ffmpeg_git_with_fdk_aac_n4.4.3/ffmpeg_g.exe -version
ffmpeg version n4.4.3-ffmpeg-windows-build-helpers Copyright (c) 2000-2022 the FFmpeg deve
lopers
built with gcc 10.2.0 (GCC)
configuration: --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=ffmpeg-
windows-build-helpers --enable-version3 --disable-debug --disable-w32threads --arch=x86_64
 --target-os=mingw32 --cross-prefix=/home/user/ffmpeg-windows-build-helpers/sandbox/cross_
compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --enable-libcaca --enable-gray --enable
-libtesseract --enable-fontconfig --enable-gmp --enable-libass --enable-libbluray --enable
-libbs2b --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enab
le-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-am
rnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enab
le-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvor
bis --enable-libwebp --enable-libzimg --enable-libzvbi --enable-libmysofa --enable-libopen
jpeg --enable-libopenh264 --enable-libvmaf --enable-libsrt --enable-libxml2 --enable-openg
l --enable-libdav1d --enable-cuda-llvm --enable-gnutls --enable-libaom --enable-nvenc --en
able-nvdec --extra-libs=-lharfbuzz --extra-libs=-lm --extra-libs=-lshlwapi --extra-libs=-l
mpg123 --extra-libs=-lpthread --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_
STATIC --extra-cflags=-DCACA_STATIC --enable-amf --enable-libmfx --enable-gpl --enable-fre
i0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-
avisynth --enable-libaribb24 --enable-libxvid --enable-libdavs2 --enable-libxavs2 --enable
-libxavs --extra-cflags='-mtune=generic' --extra-cflags=-O3 --enable-static --disable-shar
ed --prefix=/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_
64/x86_64-w64-mingw32 --disable-libdav1d --enable-nonfree --enable-libfdk-aac --enable-dec
klink
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100


● FFmpeg 4.4.3をビルドします

 --disable-nonfreeは nを設定します。
 フリー{じゃない}ライセンスのライブラリを{無効}を「いいえ」。
 ※ {二重否定}なので「いいえ」で FDK-AACが有効になる

引数意味
--build-ffmpeg-static=yDLLが不要の実行ファイルを作る(EXEファイルに DLLを含める)
--build-intel-qsv=yIntel QSVを有効にする Intel Quick Sync Video
--build-amd-amf=yAMD AMFを有効にする AMD Advanced Media Framework
--disable-nonfree=nFDK AAC等を有効にする
--ffmpeg-git-checkout-version=n4.4.3バージョン 4.4.3をビルドする
 ※ 2023年 1月現在 4.4.x系は 4.4.3が最新
FFmpeg 4.4.3 release n4.4.3 on Oct 10 2022 4bc4caf


●以下はオリジナルの ffmpeg-windows-build-helpersを使う場合の手順

# Ubuntu 22.04では下記のエラーが出るので手動でインストールする
# lensfun_git from setuptools import setup
sudo apt-get install -y python3-setuptools

# 原因は ffmpeg-windows-build-helpersが 22.04に対応していない

# Debianでは「wgetが無いよ」で先に進めないので手動でインストールする
sudo apt-get install -y wget

# Debianでは下記のエラーが出るので手動でインストールする
# lensfun ModureNotFoundError: No module named 'setuptools'
sudo apt-get install -y python3-setuptools

# ffmpeg-windows-build-helpersをダウンロードする
cd
git clone https://github.com/rdp/ffmpeg-windows-build-helpers
cd ffmpeg-windows-build-helpers

# Ubuntu/ Debianで下記のエラーが出るので OCR機能を無効にする
# ERROR: tesseract not found using pkg-config
# OCR機能は使用しないので無効にする
sed -i -e "s/ build_libtesseract/ # build_libtesseract/g" cross_compile_ffmpeg.sh
sed -i -e "s/--enable-libtesseract//g" cross_compile_ffmpeg.sh

# FFmpeg 4.4.3 for Windows
./cross_compile_ffmpeg.sh --build-ffmpeg-static=y --build-intel-qsv=y --build-amd-amf=y --disable-nonfree=n --ffmpeg-git-checkout-version=n4.4.3


● Could not find the following execs

 不足しているパッケージをインストールする。

Could not find the following execs: nasm x86_64-w64-mingw32-g++ i686-w64-mingw32-g++ i686-w64-mingw32-gcc

on ubuntu: sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 yasm make automake autoconf git pkg-config libtool-bin nasm gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 -y
Install the missing packages before running this script.

# 下記を実行する
sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 yasm make automake autoconf git pkg-config libtool-bin nasm gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 -y

● windows WSL detected: you must first disable 'binfmt' by running this

 WSLで Windowsのバイナリを実行できる機能を無効にする。

windows WSL detected: you must first disable 'binfmt' by running this

# 下記を実行する
sudo bash -c 'echo 0 > /proc/sys/fs/binfmt_misc/WSLInterop'

● Welcome to the ffmpeg cross-compile builder-helper script.

 下記の画面が出たら 1~5の数字を入力する。

 Win64 (64-bit only)の場合は 3を入力する。

     ##################### Welcome ######################
  Welcome to the ffmpeg cross-compile builder-helper script.
  Downloads and builds will be installed to directories within /home/user/ffmpeg-windows-build-helpers/sandbox
  If this is not ok, then exit now, and cd to the directory where you'd
  like them installed, then run this script again from there.
  NB that once you build your compilers, you can no longer rename/move
  the sandbox directory, since it will have some hard coded paths in there.
  You can, of course, rebuild ffmpeg from within it, etc.
Wed Jan 18 20:44:35 JST 2023

Building in /home/user/ffmpeg-windows-build-helpers/sandbox, will use ~ 12GB space!

sit back, this may take awhile...
What version of MinGW-w64 would you like to build or update?
  1. Both Win32 and Win64
  2. Win32 (32-bit only)
  3. Win64 (64-bit only)
  4. Local native
  5. Exit
Input your choice [1-5]: 3

# Win64 (64-bit only)で 3を入力する

 ビルドが完了するまで 1時間くらい待つ。


● SourceForgeはサーバが不安定

libisl isl Files

Unable to find any mirror information for the "/isl-0.23.tar.xz" file. Please select another file.

この場合は諦めて次の日に再実行する。


● lensfun ModureNotFoundError: No module named 'setuptools'

 Debianでは 2023年 1月現在も発生します。

lensfun ModureNotFoundError: No module named 'setuptools'

sudo apt-get install -y python3-setuptools


● lensfun_git from setuptools import setup

 Ubuntu 22.04では 2023年 1月現在も発生します。

lensfun_git from setuptools import setup

sudo apt-get install -y python3-setuptools

ffmpeg-windows-build-helpers/docker/Dockerfile

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


● ERROR: tesseract not found using pkg-config

Build ffmpeg with the --enable-libtesseract option #297

Fresh build: tesseract not found using pkg-config #312

 Ubuntu 22.04では 2023年 1月現在も発生します。
 ※ Ubuntu 20.04は大丈夫

ERROR: tesseract not found using pkg-config

OCR機能は使用しないので無効にする

sed -i -e "s/ build_libtesseract/ # build_libtesseract/g" cross_compile_ffmpeg.sh
sed -i -e "s/--enable-libtesseract//g" cross_compile_ffmpeg.sh


● server certificate verification failed. CAfile: none CRLfile: none

 Windows 10 WSL Ubuntu 20.04

$ ./cross_compile_ffmpeg.sh

+ git clone --depth 1 https://code.videolan.org/videolan/x264.git
Cloning into 'x264'...
fatal: unable to access 'https://code.videolan.org/videolan/x264.git/': server certificate verification failed. CAfile: none CRLfile: none
+ exit 1

git config --global http.sslverify false


● your meson version is too old 0.37.1 wanted 0.49.2

 Windows 10 WSL Debian 9.5
your meson version is too old 0.37.1 wanted 0.49.2

sudo apt-get install python3-pip -y -q
sudo pip3 install --upgrade meson ninja


● make: *** [Makefile:4232: tests/write_read_test.c] Aborted (core dumped)

 Windows 10 WSL Ubuntu 20.04

libsndfile fails to build on Ubuntu 20.04 with WSL #452

make[1]: Entering directory '/home/user/ffmpeg-windows-build-helpers/sandbox/win64/libsndfile_git'
make[1]: 'tests/pipe_test.def' is up to date.
make[1]: Leaving directory '/home/user/ffmpeg-windows-build-helpers/sandbox/win64/libsndfile_git'
make: *** [Makefile:4232: src/test_endswap.c] Aborted (core dumped)
make: *** Waiting for unfinished jobs....
Wrong __data_start/_end pair
cd ./tests && autogen --writable pipe_test.def
make[1]: Entering directory '/home/user/ffmpeg-windows-build-helpers/sandbox/win64/libsndfile_git'
make[1]: 'tests/rdwr_test.def' is up to date.
make[1]: Leaving directory '/home/user/ffmpeg-windows-build-helpers/sandbox/win64/libsndfile_git'
cd ./tests && autogen --writable rdwr_test.def
make: *** [Makefile:4232: tests/write_read_test.c] Aborted (core dumped)
make: *** [Makefile:4232: tests/pcm_test.c] Aborted (core dumped)
Wrong __data_start/_end pair
make: *** [Makefile:4232: tests/header_test.c] Aborted (core dumped)
Wrong __data_start/_end pair
make: *** [Makefile:4232: tests/utils.c] Aborted (core dumped)
Wrong __data_start/_end pair
make: *** [Makefile:4232: tests/scale_clip_test.c] Aborted (core dumped)
Wrong __data_start/_end pair
make: *** [Makefile:4232: tests/pipe_test.c] Aborted (core dumped)
Wrong __data_start/_end pair
make: *** [Makefile:4232: tests/rdwr_test.c] Aborted (core dumped)
sudo dpkg -r --force-depends "libgc1c2" # remove old libgc
# Removing libgc1c2:amd64 (1:7.6.4-0.4ubuntu1) ...

cd
git clone https://github.com/ivmai/bdwgc --depth 1
cd bdwgc
./autogen.sh
./configure --prefix=/usr && make -j # its default is the wrong directory? huh?
sudo make install
cd ..


● ERROR: The certificate of ‘downloads.sourceforge.net’ is not trusted.

 Windows 10 WSL Debian 9.5
make[1]: Leaving directory './ffmpeg-windows-build-helpers/sandbox/cross_compilers/pkgs/mpc/build'
ERROR: The certificate of ‘downloads.sourceforge.net’ is not trusted.
ERROR: The certificate of ‘downloads.sourceforge.net’ has expired.
Failure building 64 bit gcc? Recommend nuke sandbox (rm -rf sandbox) and start over...

sudo apt-get install ca-certificates
sudo update-ca-certificates
sudo dpkg-reconfigure ca-certificates
 上記では解決できない。

証明書を無視する方法でも良いが、Debian 9.5は捨てる。


● error: no matching function for call to 'IDeckLinkInput::DoesSupportVideoMode

 FFmpeg 4.2.x系はビルドでエラーになる。

Compiling and installing ffmpeg with Decklink support on Ubuntu 18.04 Server

libavdevice/decklink_common.cpp: In function 'int ff_decklink_set_format(AVFormatContext*, int, int, int, int, AVFieldOrder, decklink_direction_t, int)':
libavdevice/decklink_common.cpp:277:52: error: no matching function for call to 'IDeckLinkInput::DoesSupportVideoMode(BMDVideoConnection&, BMDDisplayMode&, BMDPixelFormat, _BMDSupportedVideoModeFlags, BOOL*)'
  277 |                                            &support) != S_OK)
      |                                                    ^
In file included from libavdevice/decklink_common.cpp:28:
/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/DeckLinkAPI.h:6308:39: note: candidate: 'virtual HRESULT IDeckLinkInput::DoesSupportVideoMode(BMDVideoConnection, BMDDisplayMode, BMDPixelFormat, BMDVideoInputConversionMode, BMDSupportedVideoModeFlags, BMDDisplayMode*, BOOL*)'
 6308 |     virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
      |                                       ^~~~~~~~~~~~~~~~~~~~
/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/DeckLinkAPI.h:6308:39: note:   candidate expects 7 arguments, 5 provided
libavdevice/decklink_common.cpp:283:65: error: no matching function for call to 'IDeckLinkOutput::DoesSupportVideoMode(_BMDVideoConnection, BMDDisplayMode&, BMDPixelFormat&, _BMDSupportedVideoModeFlags, BMDDisplayMode*, BOOL*)'
  283 |                                            &actualMode, &support) != S_OK || !support || ctx->bmd_mode != actualMode) {

--ffmpeg-git-checkout-version=n4.2.x
  ↓
--ffmpeg-git-checkout-version=n4.4.x


● Debian

 Debianは gitが標準で入っていないので不便。

# Debianの環境を更新する
sudo apt update

# gitをインストールする
sudo apt -y install git


●その他

quick_build/quick_cross_compile_ffmpeg_fdk_aac_and_x264_using_packaged_mingw64.sh

でビルドしても FDK AACが使えないかった???

$ ./cross_compile_ffmpeg.sh --build-ffmpeg-static=y --build-intel-qsv=y --disable-nonfree=n

$ ls -l ./sandbox_quick/win64/quick_install/install_root/ffmpeg_simple_installed/bin/
-rwxr-xr-x 1 user user 31078400 Jan 18 16:46 ffmpeg.exe
-rwxr-xr-x 1 user user 30913024 Jan 18 16:46 ffprobe.exe

$ ls -l ./sandbox_quick/win64/quick_install/install_root/bin/
-rwxr-xr-x 1 user user 3669380 Jan 18 16:36 x264.exe

Everything is Ok
You will find redistributable archive .7z file in /home/user/ffmpeg-windows-build-helpers/sandbox/redist
Thu Jan 19 00:16:11 JST 2023
searching for all local exe's (some may not have been built this round, NB)...
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffmpeg.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_n4.2.8/ffmpeg.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_n4.2.8/ffmpeg_g.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/ffplay.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_n4.2.8/ffplay.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/share/doc/ffmpeg
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/share/ffmpeg
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/x264.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/x264_all_bitdepth/x264.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/bin/x265.exe
built /home/user/ffmpeg-windows-build-helpers/sandbox/win64/x265_all_bitdepth/8bit/x265.exe

> ffmpeg -version
ffmpeg version n4.2.8-ffmpeg-windows-build-helpers Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 10.2.0 (GCC)
configuration: --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=ffmpeg-windows-build-helpers --enable-version3 --disable-debug --disable-w32threads --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --enable-libcaca --enable-gray --enable-libtesseract --enable-fontconfig --enable-gmp --enable-libass --enable-libbluray --enable-libbs2b --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libwebp --enable-libzimg --enable-libzvbi --enable-libmysofa --enable-libopenjpeg --enable-libopenh264 --enable-libvmaf --enable-libsrt --enable-libxml2 --enable-opengl --enable-libdav1d --enable-cuda-llvm --enable-gnutls --enable-libaom --enable-nvenc --enable-nvdec --extra-libs=-lharfbuzz --extra-libs=-lm --extra-libs=-lshlwapi --extra-libs=-lmpg123 --extra-libs=-lpthread --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCACA_STATIC --enable-amf --enable-libmfx --enable-gpl --enable-frei0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-avisynth --enable-libaribb24 --enable-libxvid --enable-libdavs2 --enable-libxavs2 --enable-libxavs --extra-cflags='-mtune=generic' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/home/user/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --disable-libdav1d
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

● Debian
# Windows 10 22H2 Debian
cat /etc/debian_version
# 9.5

# Windows 11 22H2 Debian
cat /etc/debian_version
# 11.6



Tags: [Raspberry Pi], [電子工作]

●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)

【2023年】Raspberry Piで高音質な fdk-aacを有効にした FFmpegをビルドする方法
【2023年】Raspberry Piで高音質な fdk-aacを有効にした FFmpegをビルドする方法

  ラズパイで Fraunhofer FDK AACが使える FFmpegを自分でコンパイルしてインストールする方法

Raspberry Pi 3 Model Bで動画処理アプリ FFmpegをコンパイルする方法
Raspberry Pi 3 Model Bで動画処理アプリ FFmpegをコンパイルする方法

  ラズパイ3で動画音声変換処理プログラム FFmpegをセルフコンパイルしてインストールする方法

【2020年版】NVIDIA Jetson Nano対応の FFmpegをビルドする手順
【2020年版】NVIDIA Jetson Nano対応の FFmpegをビルドする手順

  NVIDIA Jetson Nano対応の FFmpegをビルドする手順、x264と x265にも対応




[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2023 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/software/windows_compile_ffmpeg_enable_fdk_aac/