Ubuntu20 ffmpeg + avisynth + delogo + JoinLogoScp で自動CMカットエンコード環境構築

avisynthffmpeg の公式インストール手順
https://github.com/AviSynth/AviSynthPlus/blob/3.5/distrib/docs/english/source/avisynthdoc/contributing/posix.rst


avisynth のインストール

# add-apt-repository ppa:ubuntu-toolchain-r/test
# apt update
# apt install build-essential cmake git ninja-build gcc-9 g++-9 checkinstall

# cd /usr/local/src
# git clone git://github.com/AviSynth/AviSynthPlus.git
# cd AviSynthPlus
# mkdir avisynth-build
# cd avisynth-build
# CC=gcc-9 CXX=gcc-9 LD=gcc-9 cmake ../ -G Ninja
# ninja
# checkinstall \
   --pkgname=avisynth \
   --pkgversion="$(grep -r Version avs_core/avisynth.pc | cut -f2 -d " ")-$(date --rfc-3339=date | sed 's/-//g')-git" \
   --backup=no \
   --deldoc=yes \
   --delspec=yes \
   --deldesc=yes \
   --strip=yes \
   --stripso=yes \
   --addso=yes \
   --fstrans=no \
   --default ninja install


ffmpeg のインストール

# apt install nasm libfdk-aac-dev libx264-dev libx265-dev

# cd /usr/local/src
# git clone git://git.ffmpeg.org/ffmpeg.git
# cd ffmpeg
# ./configure \
  --enable-gpl \
  --enable-version3 \
  --disable-doc \
  --disable-debug \
  --enable-avisynth \
  --enable-libfdk-aac \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree
# make
# make install


・l-smash のインストール

# cd /usr/local/src/
# git clone https://github.com/l-smash/l-smash.git
# cd l-smash
# ./configure --enable-shared
# make
# make install
# ldconfig


・l-smash-works のインストール(avisynth で l-smash を使用するためのプラグイン

# apt install python3-pip
# pip3 install meson

# cd /usr/local/src/
# git clone https://github.com/HolyWu/L-SMASH-Works.git
# cd L-SMASH-Works/AviSynth
# git checkout 72d3eac802eebcfc9080009c1a8d47a747e3a306
# CC=gcc-9 CXX=gcc-9 LD=gcc-9 LDFLAGS="-Wl,-Bsymbolic" meson build
# cd build
# ninja -v
# ninja install
# ldconfig


・JoinLogoScpTrialSet for Linux and Avisynth+3.5.x のインストール
https://github.com/tobitti0/JoinLogoScpTrialSetLinux

# cd /usr/local/src/
# mkdir JoinLogoScpTrialSetLinux
# cd JoinLogoScpTrialSetLinux
# git clone --recursive https://github.com/tobitti0/JoinLogoScpTrialSetLinux.git
# cd JoinLogoScpTrialSetLinux/modules/chapter_exe/src/
# make
# cp -a chapter_exe /usr/local/bin/.
# cd ../../logoframe/src/
# make
# cp -a logoframe /usr/local/bin/.
# cd ../../join_logo_scp/src/
# make
# cp -a join_logo_scp /usr/local/bin/.


・join_logo_scp の動作確認

# cd ~
# vi join_temp.avs
TSFilePath="GR27_test.ts"
LWLibavVideoSource(TSFilePath, repeat=true, dominance=1)
AudioDub(last,LWLibavAudioSource(TSFilePath, av_sync=true))

# chapter_exe -v join_temp.avs -oa temp_inscp.txt
# logoframe join_temp.avs -logo GR27.lgd -oa temp_inlogo.txt
# join_logo_scp -inlogo temp_inlogo.txt -inscp temp_inscp.txt -incmd JL_標準.txt -o temp_join_logo_scp.txt

# cat temp_join_logo_scp.txt
※Trim情報が記載されていること


・透過性ロゴ フィルタ for AviSynth+ 3.5.x & Linux のインストール
https://github.com/tobitti0/delogo-AviSynthPlus-Linux

# cd /usr/local/src/
# git clone https://github.com/tobitti0/delogo-AviSynthPlus-Linux.git
# cd delogo-AviSynthPlus-Linux/src
# make CC=gcc-9 CXX=gcc-9 LD=gcc-9
# make install
# ldconfig


・delogo の動作確認

# cd ~
# vi delogo_temp.avs
TSFilePath="GR27_test.ts"
LWLibavVideoSource(TSFilePath, repeat=true, dominance=1)
AudioDub(last,LWLibavAudioSource(TSFilePath, av_sync=true))
EraseLOGO(logofile="GR27.lgd", interlaced=true)

# ffmpeg -f avisynth -i delogo_temp.avs --vcodec libx264 -acodec libfdk_aac GR27_test.mp4