30.12.2025, 02:42
I did end up getting this to work as I wanted. I ended up using this for the external call:
"C:\Windows\System32\cmd.exe" /d /s /c start "Hybrid post-queue" cmd.exe /k ""F:\SBP\SCRIPTS\queue_done.cmd""
And this is the contents of queue_done.cmd:
Then the encode .bat file is:
This kicks off a ladder encode of all files recently processed from the Hybrid queue in a new window, titled for the process, that shows the progress of the encode as if kicked off manually. The source file is encoded to 2160p, 1440p, 1080p, and 720p for each resolution that the source file supports. Ie a 1600p video gets encoded to 1440p, 1080p, and 720p, while preserving aspect ratio. It also encodes to BT709, full range color, which is specific to my workflow. Also PCM audio is converted to AAC 192KB, and all other audio formats are copied (again, specific to my flow). You can always tweak as needed for anyone interested in using it.
The x265 encode command I literally spent a couple weeks testing to find the command that preserved original details the best. The result of this command even looks good when pixel peeping frame by frame. I have not tested it on animated content, but I expect it would require tweaks for that type of content.
"C:\Windows\System32\cmd.exe" /d /s /c start "Hybrid post-queue" cmd.exe /k ""F:\SBP\SCRIPTS\queue_done.cmd""
And this is the contents of queue_done.cmd:
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set "WORKDIR=F:\SBP\RESIZE"
set "LOG=F:\SBP\SCRIPTS\hybrid_queue_done.log"
set "LOCKDIR=%TEMP%\hybrid_queue_done.lockdir"
REM Prevent overlapping runs
mkdir "%LOCKDIR%" 2>nul
if errorlevel 1 (
echo Another run is already active. Exiting.
>>"%LOG%" echo [%date% %time%] Another run already active; exiting.
exit /b 0
)
REM Log header (this does NOT hide console output)
>>"%LOG%" echo.
>>"%LOG%" echo ===== %date% %time% =====
>>"%LOG%" echo User=%USERNAME%
>>"%LOG%" echo WorkingDir=%CD%
pushd "%WORKDIR%" || (
echo ERROR: cannot cd to "%WORKDIR%"
>>"%LOG%" echo ERROR: cannot cd to "%WORKDIR%"
rmdir "%LOCKDIR%" 2>nul
exit /b 1
)
echo Running post-queue script in: %CD%
echo (This window will show ffmpeg progress. Closing it will stop the encode.)
REM IMPORTANT: no redirection here, so you see live progress
call "F:\SBP\RESIZE\PostQ - Ladder - x265 SBP Tuned - CRF22 Slow - Full Color 10bit BT709 - Encode Aud.bat" nopause
set "EC=%errorlevel%"
echo Encode finished. ExitCode=%EC%
>>"%LOG%" echo ExitCode=%EC%
popd
rmdir "%LOCKDIR%" 2>nul
exit /b %EC%Then the encode .bat file is:
@echo off
setlocal EnableExtensions EnableDelayedExpansion
REM Run from your working folder
pushd "F:\SBP\RESIZE" || exit /b 1
REM Prevent overlapping runs (Hybrid hook can fire twice)
set "LOCK=%TEMP%\hybrid_encode.lock"
if exist "%LOCK%" exit /b 0
> "%LOCK%" echo %DATE% %TIME%
REM Ensure output folder exists
if not exist "F:\SBP\NAME" mkdir "F:\SBP\NAME" >nul 2>&1
for %%f in (*.mp4 *.mov *.mxf *.mkv) do (
if exist "%%f" call :processOne "%%f"
)
del "%LOCK%" 2>nul
popd
REM Only pause when run manually (no args)
if "%~1"=="" pause
exit /b 0
:processOne
set "source_file=%~1"
set "source_name=%~n1"
set "source_height="
set "acodec="
set "AOPTS=-c:a copy"
REM ---- Get source height ----
for /f "usebackq delims=" %%h in (`
ffprobe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%source_file%"
`) do set "source_height=%%h"
REM Validate numeric height; skip if ffprobe failed
for /f "delims=0123456789" %%x in ("!source_height!") do set "source_height="
if not defined source_height exit /b 0
REM ---- Get audio codec (if any) ----
for /f "usebackq delims=" %%a in (`
ffprobe -v error -select_streams a:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%source_file%"
`) do set "acodec=%%a"
REM If PCM audio, encode to AAC 192k; otherwise copy
if defined acodec (
if /i "!acodec:~0,4!"=="pcm_" set "AOPTS=-c:a aac -b:a 192k"
)
REM ---- Encode ladder (only rungs <= source height) ----
for %%r in (2160 1440 1080 720) do (
if !source_height! GEQ %%r (
set "OUT=F:\SBP\NAME\!source_name! - %%r.mp4"
ffmpeg -y -nostdin -flush_packets 1 -i "%source_file%" ^
-map 0:v:0 -map 0:a:0? ^
-vf "scale=w=-1:h=%%r:flags=lanczos+accurate_rnd+full_chroma_int,zscale=matrix=709:transfer=709:primaries=709:range=full,format=yuv420p10le" ^
-c:v libx265 -profile:v main10 -preset slow -crf 22 ^
-x265-params "asm=avx512:pme=0:pmode=0:aq-strength=1.1:psy-rdoq=1.7:psy-rd=3.00:rd=4:ssim-rd=1:wpp=1:crqpoffs=-3:rect=0:ctu=32:rc-lookahead=60:subme=4:merange=32:min-cu-size=8:max-tu-size=32:tu-inter-depth=2:tu-intra-depth=2:qcomp=0.65:selective-sao=0:no-sao=1:early-skip=0:fast-intra=1:bframes=5:strong-intra-smoothing=0:keyint=300:min-keyint=28:aq-mode=3:rskip=2:deblock=-2,-2" ^
!AOPTS! ^
-movflags +faststart "!OUT!"
if errorlevel 1 del /q "!OUT!" 2>nul
)
)
exit /b 0This kicks off a ladder encode of all files recently processed from the Hybrid queue in a new window, titled for the process, that shows the progress of the encode as if kicked off manually. The source file is encoded to 2160p, 1440p, 1080p, and 720p for each resolution that the source file supports. Ie a 1600p video gets encoded to 1440p, 1080p, and 720p, while preserving aspect ratio. It also encodes to BT709, full range color, which is specific to my workflow. Also PCM audio is converted to AAC 192KB, and all other audio formats are copied (again, specific to my flow). You can always tweak as needed for anyone interested in using it.
The x265 encode command I literally spent a couple weeks testing to find the command that preserved original details the best. The result of this command even looks good when pixel peeping frame by frame. I have not tested it on animated content, but I expect it would require tweaks for that type of content.

