-
-
Save nyanshiba/dee62ebd7a7d102db52cb25aa9e54819 to your computer and use it in GitHub Desktop.
ウォータマーク(局ロゴ)を消す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo on | |
rem TSファイルをD&Dで動作する | |
rem txtやpngはTSファイルと同じディレクトリに作成された、TSファイルと同じ名前のフォルダに生成される | |
rem 出力フォルダ作成 | |
md "%~dp1\%~n1" | |
rem 99%黒いキーフレームの時間をlogo.txtに出力 | |
ffmpeg -hide_banner -nostats -skip_frame nokey -i %1 -an -vf field=0,blackframe=amount=99 -f null - 2> "%~dp1\%~n1\logo.txt" | |
rem logo.txt内をfidstrでソート | |
findstr "Parsed_blackframe_1" "%~dp1\%~n1\logo.txt" > "%~dp1\%~n1\logo2.txt" | |
rem はじめに行カウントを1にしておく | |
set cnt=1 | |
rem 複数行ある場合は2行目からはここにループする | |
:loop | |
rem 環境変数ssをクリア | |
set ss= | |
rem テキストから1行ずつ読み出し、読み出した行から区切り文字を":"、" "とし、12番目のトークンを環境変数ssに格納 | |
rem [Parsed_blackframe_1 @ 000002996eecee80] frame:596 pblack:99 pts:53795742 t:298.865233 type:I last_keyframe:596 | |
for /f "tokens=12 delims=: " %%a in ('findstr /n /r "." "%~dp1\%~n1\logo2.txt" ^| findstr /r "^%cnt%:"') do ( | |
set ss=%%a | |
) | |
rem 環境変数ssが設定されていれば実行、されていなければテキストファイルの終了とみなす | |
if defined ss ( | |
rem 環境変数ssに格納された時間をもとにグレースケールpngを出力 | |
ffmpeg -v fatal -y -ss %ss% -i %1 -vf bwdif=0:-1:1,format=gray -vframes 1 "%~dp1\%~n1\logo_%cnt%.png" | |
rem 行カウントを1上げてループ | |
set /a cnt=cnt+1 | |
goto :loop | |
) | |
rem ffmpegで画像の2値化&輪郭グラデ、元画像削除 | |
rem 5000~10000 | |
for /r "%~dp1\%~n1" %%a in ( *.png ) do ( | |
call :binari "%%a" | |
) | |
rem 環境変数ssが設定されていなければテキストファイルの終了とみなし終了 | |
pause | |
exit | |
rem ffmpegで画像の2値化&輪郭グラデサブルーチン | |
:binari | |
rem magick convert -threshold 15000 -type GrayScale %1 "%~dpn1_b.png" | |
ffmpeg -i %1 -vf lutrgb=r=between(val\,11\,255)*val:g=between(val\,11\,255)*val:b=between(val\,11\,255)*val,colorchannelmixer=1.25:1.25:1.25:0:1.25:1.25:1.25:0:1.25:1.25:1.25:0,format=gray "%~dpn1_b.png" | |
rem 元画像削除 | |
del %1 | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment