I have refined my SSIM/AV1 windows batch script.
@echo off & setlocal enabledelayedexpansion & set "crf=60" & set "mincrf=20"
set "base_av1=-c:v libsvtav1 -preset 10 -pix_fmt yuv420p10le -svtav1-params"
set "psy_av1=keyint=2s:lookahead=120:tune=0:enable-variance-boost=1:variance-boost-strength=3:variance-octile=4"
set "opus=-c:a libopus -b:a 128k" & set "ffquiet=-hide_banner -loglevel quiet"
echo Weclome to my auto-SSIM AV1 encoder, only input.mp4 accepted, choose desired SSIM:
echo 1= 0.995 (autism quality) & echo 2= 0.990 (very high quality) & echo 3= 0.980 (high quality)
choice /c 123 /m "Enter number option on keyboard: "
if errorlevel 3 set ssim_target=980
if errorlevel 2 set ssim_target=990
if errorlevel 1 set ssim_target=995
:loop
ffmpeg !ffquiet! -i input.mp4 -crf !crf! !base_av1! !psy_av1! !opus! -y AV1_CRF-!crf!.webm 2>nul
for /f "delims=" %%A in ('ffmpeg -nostdin -r 30 -i AV1_CRF-!crf!.webm -nostdin -r 30 -i input.mp4 ^
-lavfi "[0:v]settb=AVTB,setpts=PTS-STARTPTS,format=yuv420p10le[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS,format=yuv420p10le[ref];[main][ref]ssim=eof_action=endall:stats_file=-" ^
-f null - 2^>^&1 ^| findstr "All:"') do set "a=%%A"
set "a=!a:*All:0.=!" & set "ssim=!a:~0,3!" & echo SSIM: 0.!ssim! @ CRF !crf! & echo:
if !ssim! lss !ssim_target! (if !crf! gtr !mincrf! (del /s /q AV1_CRF-!crf!.webm >nul 2>&1 & set /a crf-=2 & goto loop) )
:end
for %%Y in ("input.mp4") do set /a kb_mp4=(%%~zY+1023)/1024 & for %%Y in ("AV1_CRF-!crf!.webm") do set /a kb_webm=(%%~zY+1023)/1024
set /a saved_pct=(kb_mp4-kb_webm)*100/kb_mp4 & echo MP4= !kb_mp4! KB & echo AV1= !kb_webm! KB
echo **** !saved_pct!%% filesize reduction achieved with AV1 **** & echo:
pause