>>105821060@echo off
setlocal enabledelayedexpansion
:: -------------------------------
:: Configuration
:: -------------------------------
set "FFMPEG_PATH=T:\Recordings\ffmpeg.exe"
set "FPS=50/3"
set "START_FRAME=STARTFRAME#" :: Replace with actual start frame number
set "END_FRAME=ENDFRAME#" :: Replace with actual end frame number
:: -------------------------------
:: Input Validation
:: -------------------------------
if "%~1"=="" (
echo [ERROR] No input file provided.
echo Usage: %~nx0 input_video
exit /b 1
)
if not exist "%~1" (
echo [ERROR] Input file "%~1" does not exist.
exit /b 1
)
if not exist "%FFMPEG_PATH%" (
echo [ERROR] ffmpeg not found at "%FFMPEG_PATH%"
exit /b 1
)
:: -------------------------------
:: Prepare Output Directory
:: -------------------------------
set "INPUT_FILE=%~1"
set "INPUT_DIR=%~dp1"
set "INPUT_NAME=%~n1"
set "OUTPUT_DIR=%INPUT_DIR%png"
if not exist "%OUTPUT_DIR%" (
mkdir "%OUTPUT_DIR%"
)
:: -------------------------------
:: Run ffmpeg to extract frames
:: -------------------------------
echo [INFO] Extracting frames from "%INPUT_FILE%"...
"%FFMPEG_PATH%" -i "%INPUT_FILE%" ^
-vf "select='between(n\,%START_FRAME%\,%END_FRAME%)',setpts=PTS-STARTPTS,fps=%FPS%" ^
-vcodec png -an "%OUTPUT_DIR%\%INPUT_NAME% %%04d.png"
if errorlevel 1 (
echo [ERROR] ffmpeg failed to extract frames.
exit /b 1
)
echo [SUCCESS] Frames saved to "%OUTPUT_DIR%"
pause
endlocal