@echo off
rem Финальный рендер Full HD выбранного стиля: 4 потока Chrome, 8-16 подкадров на кадр, сведение, копия в DEMO.
rem   pm_final.cmd red|acid
set V=%1
if "%V%"=="" set V=red
cd /d E:\PKSTUDIO\clients\pk_motion
if not exist out\final mkdir out\final
del /q out\final\v3_%V%_s*.mp4 out\final\v3_%V%_l*.txt 2>nul
start "a" /b cmd /c "node tools\pm_capture.mjs --page web_v\index.html --v %V% --out out\final\v3_%V%_s0.mp4 --from 0 --to 450 --port 9380 > out\final\v3_%V%_l0.txt 2>&1"
start "b" /b cmd /c "node tools\pm_capture.mjs --page web_v\index.html --v %V% --out out\final\v3_%V%_s1.mp4 --from 450 --to 900 --port 9381 > out\final\v3_%V%_l1.txt 2>&1"
start "c" /b cmd /c "node tools\pm_capture.mjs --page web_v\index.html --v %V% --out out\final\v3_%V%_s2.mp4 --from 900 --to 1350 --port 9382 > out\final\v3_%V%_l2.txt 2>&1"
node tools\pm_capture.mjs --page web_v\index.html --v %V% --out out\final\v3_%V%_s3.mp4 --from 1350 --to 1800 --port 9383 > out\final\v3_%V%_l3.txt 2>&1
:wait
ping -n 6 127.0.0.1 >nul
for %%i in (0 1 2) do findstr /c:"frames_done" out\final\v3_%V%_l%%i.txt >nul || goto wait
(echo file '%V%_s0.mp4'& echo file '%V%_s1.mp4'& echo file '%V%_s2.mp4'& echo file '%V%_s3.mp4') > out\final\v3_%V%_list.txt
C:\Users\PKSTUDIO\.cache\hyperframes\ffmpeg\ffmpeg-9.0.1-essentials_build\bin\ffmpeg.exe -v error -y -f concat -safe 0 -i out\final\v3_%V%_list.txt -c copy out\final\v3_%V%_video.mp4
node tools\pm_capture.mjs --page web_v\index.html --v %V% --cues out\cues.json --port 9384
python tools\pm_assemble.py --music C --video out\final\v3_%V%_video.mp4 --out pk_motion_v3_%V%
echo FINAL_DONE
