From 056729492374fc8335532dde6dfa8594645948ac Mon Sep 17 00:00:00 2001 From: Jan-Weigang <78200364+Jan-Weigang@users.noreply.github.com> Date: Sat, 14 Aug 2021 15:19:10 +0200 Subject: [PATCH] Add files via upload --- _Timelapse Creator 1.0.1.bat | 667 +++++++++++++++++++++++++++++++++++ 1 file changed, 667 insertions(+) create mode 100644 _Timelapse Creator 1.0.1.bat diff --git a/_Timelapse Creator 1.0.1.bat b/_Timelapse Creator 1.0.1.bat new file mode 100644 index 0000000..505c59e --- /dev/null +++ b/_Timelapse Creator 1.0.1.bat @@ -0,0 +1,667 @@ +setlocal enabledelayedexpansion +@echo off + +]2;Timelapse Creator by Jan Weigang + +Rem |---- Set Basic Variables ----| + +mode con: cols=120 lines=30 + +set dirfull=_Full Video +set dirproxy=_Proxy Video +set dirgifs=GIFs + +set profile=2 +set crf=18 +set keyframes=1 +set hcontainer=mov +set pcontainer=mov +set maxsize=15 + +set deflickersize=15 +set deflickermode=am +set deflicker=size=%deflickersize%:mode=%deflickermode% +set deflickertoggle=on + +set proxytoggle=off + +set motiontoggle=off + + +echo %cd%\%dirfull%\NUL + +if not exist "%dirfull%\" mkdir "%dirfull%" +if not exist "%dirproxy%\" mkdir "%dirproxy%" +if not exist "%dirgifs%\" mkdir "%dirgifs%" + + +Rem |---- Detect Images ----| + + +:images + +set imagetype=png +set name=UNDEFINED +set fps=25 + +for %%A in (*.png) do ( + set "name=%%~nA.png" + set imagetype=png + goto continue +) + + +for %%A in (*.jpg) do ( + set "name=%%~nA.jpg" + set imagetype=jpg + goto continue +) + +if name EQU UNDEFINED ( + echo No images found! Exiting... + goto end +) + + + + + +:continue + +set name=%name:~0,-8% + +Rem |---- Menu and Codec ----| + +:menu +echo.&cls +echo - - - - - Timelapse Creator by Jan Weigang - - - - - +echo. +echo Found the following %imagetype%s: %name% +echo. + + + +set codec=prores +set height=2160 +set custom=n +set bitrate=100 + +echo. +echo Pick Preset (press number to continue): +echo. +echo 1. Prores 4k +echo 2. h264 1080 +echo 3. h265 1080 +echo. +echo 5. Custom Video +echo. +echo. +echo - - advanced settings: - - +echo p. Toggle Proxy (%proxytoggle%) +echo d. Toggle Deflicker (%deflickertoggle%) +echo m. Toggle Motion Interpolation (%motiontoggle%) +echo. +echo 0. GIFs +echo. +echo  + + +choice /C 1235pdm0 /N +if %ERRORLEVEL% EQU 8 ( + set codec=gif + set height=360 + goto presetcontinue +) +if %ERRORLEVEL% EQU 7 ( + if %motiontoggle% EQU on ( + set motiontoggle=off + ) else ( + set motiontoggle=on + ) +  + goto menu +) +if %ERRORLEVEL% EQU 6 ( + if %deflickertoggle% EQU on ( + set deflickertoggle=off + set deflicker=bypass=1 + ) else ( + set deflickertoggle=on + set deflicker=size=%deflickersize%:mode=%deflickermode% + ) +  + goto menu +) +if %ERRORLEVEL% EQU 5 ( + if %proxytoggle% EQU on ( + set proxytoggle=off + ) else ( + set proxytoggle=on + ) +  + goto menu +) +if %ERRORLEVEL% EQU 4 ( + set custom=y + set width=3840 + goto presetcontinue +) +if %ERRORLEVEL% EQU 3 ( + set codec=h265 + set height=1080 + goto presetcontinue +) +if %ERRORLEVEL% EQU 2 ( + set codec=h264 + set height=1080 + goto presetcontinue +) +if %ERRORLEVEL% EQU 1 ( + set codec=prores + set height=2160 + goto presetcontinue +) + +:presetcontinue + +echo  +if %custom% EQU y goto custommenu + + + + +Rem |---- Preset Framerate ----| + + +:framerate + +set /P fps=Please enter the framerate: + +set "var="&for /f "delims=0123456789" %%i in ("%fps%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto framerate +) + +goto process + +Rem Going to Process unless GIFs are selected as preset + + + + + + + +Rem TODO: Custom Menu + +Rem |---- Custom Menu ----| + +:custommenu + +set /A ratio = %width% / %height% + +echo.&cls +echo - - - - - Timelapse Creator by Jan Weigang - - - - - +echo. +echo. +echo Pick setting to change (press number to continue): +echo. +echo 1. Codec: %codec% +echo 2. Resolution: %height%p +echo 3. Framerate: %fps% fps +echo. +echo 4. Width/Aspect %width% px +echo. + +echo - - %codec% settings: - - + +Rem |--- Prores Settings ---| +if %codec% EQU prores echo 5. Container: %pcontainer% +if %codec% EQU prores echo 6. Profile (0-5): %profile% + +Rem |--- h264 Settings ---| +if %codec% EQU h264 echo 5. Container: %hcontainer% +if %codec% EQU h264 echo 6. CRF (0-51): %crf% +if %codec% EQU h264 echo 7. Bitrate: %bitrate% Mbit +if %codec% EQU h264 echo 8. Keyframe: every %keyframes% second(s) + +Rem |--- h265 Settings ---| +if %codec% EQU h265 echo 5. Container: %hcontainer% +if %codec% EQU h265 echo 6. CRF (0-51): %crf% +if %codec% EQU h265 echo 7. Bitrate: %bitrate% Mbit +if %codec% EQU h265 echo 8. Keyframe: every %keyframes% second(s) + +Rem |--- Prores Settings ---| + +if %codec% EQU gif echo 9. Max-Size: %maxsize% MB + + +echo. +echo. +echo. +echo. +echo - - advanced settings: - - +echo p. Toggle Proxy (%proxytoggle%) +echo d. Toggle Deflicker (%deflickertoggle%) +echo m. Toggle Motion Interpolation (%motiontoggle%) +echo. +echo 0. Start rendering +echo  + + +choice /C 123456789pdm0 /N +if %ERRORLEVEL% EQU 13 goto process +if %ERRORLEVEL% EQU 12 ( + if %motiontoggle% EQU on ( + set motiontoggle=off + ) else ( + set motiontoggle=on + ) +  + goto custommenu +) +if %ERRORLEVEL% EQU 11 ( + if %deflickertoggle% EQU on ( + set deflickertoggle=off + set deflicker=bypass=1 + ) else ( + set deflickertoggle=on + set deflicker=size=%deflickersize%:mode=%deflickermode% + ) +  + goto custommenu +) +if %ERRORLEVEL% EQU 10 ( + if %proxytoggle% EQU on ( + set proxytoggle=off + ) else ( + set proxytoggle=on + ) +  + goto custommenu +) +if %ERRORLEVEL% EQU 9 goto pickfilesize +if %ERRORLEVEL% EQU 8 goto pickkeyframes +if %ERRORLEVEL% EQU 7 goto pickbitrate +if %ERRORLEVEL% EQU 6 goto pickquality +if %ERRORLEVEL% EQU 5 goto pickcontainer +if %ERRORLEVEL% EQU 4 goto pickwidth +if %ERRORLEVEL% EQU 3 goto pickfps +if %ERRORLEVEL% EQU 2 goto pickheight +if %ERRORLEVEL% EQU 1 goto pickcodec + + +Rem |---- Custom Menu - prompts ----| + +Rem 1 Codec, 2 Height, 3 FPS, 4 Width, 5 Container, 6 Profile / CRF, 7 Bitrate, 8 Keyframes (sekunden), 9 Filesize (GIF), 0 Start + + +:pickcodec +echo  + +echo.&cls +echo - - - - - Timelapse Creator by Jan Weigang - - - - - +echo. +echo. +echo Pick codec (press number to continue): +echo. +echo 1. prores +echo 2. h264 +echo 3. h265% +echo 4. GIF +echo. +echo  + +choice /C 1234 /N +if %ERRORLEVEL% EQU 4 set codec=gif +if %ERRORLEVEL% EQU 3 set codec=h265 +if %ERRORLEVEL% EQU 2 set codec=h264 +if %ERRORLEVEL% EQU 1 set codec=prores + +echo  + +goto custommenu + + + +Rem - - - - - - - - - - - - Custom height: + +:pickheight +echo  + +set /P height=Please enter y-resolution: + +set "var="&for /f "delims=0123456789" %%i in ("%height%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickheight +) + +set /A width=%height% * 16 / 9 + +goto custommenu + + + +Rem - - - - - - - - - - - - Custom FPS: + +:pickfps +echo  + +set /P fps=Please enter the framerate: + +set "var="&for /f "delims=0123456789" %%i in ("%fps%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickfps +) + +goto custommenu + + + +Rem - - - - - - - - - - - - Custom Bitrate: + +:pickbitrate +echo  + +set /P bitrate=Please enter the bitrate: + +set "var="&for /f "delims=0123456789" %%i in ("%bitrate%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickbitrate +) + +goto custommenu + + + +Rem - - - - - - - - - - - - Custom Width: + +:pickwidth +echo  + +echo Warning: Picking Width (instead of height) changes the aspect ratio. Set height first. +echo Current Value: %width% px +echo. +echo. + +set /P width=Please enter x-dimension: + +set "var="&for /f "delims=0123456789" %%i in ("%width%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickwidth +) + +goto custommenu + + + + + +Rem - - - - - - - - - - - - Custom Container: + +:pickcontainer +echo  + +echo.&cls +echo - - - - - Timelapse Creator by Jan Weigang - - - - - +echo. +echo. +echo Pick codec (press number to continue): +echo. +echo 1. mov +if %codec% EQU prores ( + echo 2. mkv +) else ( + echo 2. mp4 +) + +echo. +echo  + +choice /C 12 /N +if %ERRORLEVEL% EQU 2 ( + if %codec% EQU prores ( + set pcontainer=mkv + ) else ( + set hcontainer=mp4 + ) +) +if %ERRORLEVEL% EQU 1 ( + if %codec% EQU prores ( + set pcontainer=mov + ) else ( + set hcontainer=mov + ) +) + +echo  + +goto custommenu + + + +Rem - - - - - - - - - - - - Custom Quality: + +:pickquality +echo  + +if %codec% EQU prores echo Current Value: %profile% +if %codec% NEQ prores echo Current Value: %crf% +echo. + +if %codec% EQU prores set /P profile=Please enter profile: +if %codec% NEQ prores set /P crf=Please enter crf value: + +set "var="&for /f "delims=0123456789" %%i in ("%profile%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickquality +) + +set "var="&for /f "delims=0123456789" %%i in ("%crf%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickquality +) + +goto custommenu + + + + +Rem - - - - - - - - - - - - Custom keyframes: + +:pickkeyframes +echo  + +echo Current Value: Keyframe every %keyframes% second(s) +echo. +echo. + +set /P keyframes=Please enter seconds: + +set "var="&for /f "delims=0123456789" %%i in ("%keyframes%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickkeyframes +) + +goto custommenu + + + +Rem - - - - - - - - - - - - Custom filesize (gif): + +:pickfilesize +echo  + +echo Current Value: %maxsize% MB +echo. +echo. + +set /P maxsize=Please enter maximum filesize for short gif: + +set "var="&for /f "delims=0123456789" %%i in ("%maxsize%") do set var=%%i +if defined var ( + echo Entered Value is not numeric + goto pickfilesize +) + +goto custommenu + + + + + + +Rem |------------------------------ Start of Process ------------------------------------| + +:process + +set deflickername= +if %deflickertoggle% EQU on set deflickername=_deflicker +set motionname= +if %motiontoggle% EQU on set motionname=x2 + +set /A doublefps=%fps% * 2 +set motion= +if %motiontoggle% EQU on set motion=,minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=%doublefps%:me=ds' + +if %custom% EQU n set /A width = %height% * 16 / 9 + +if %codec% EQU gif goto processgifs + +if %custom% EQU n set /A bitrate = (%bitrate% + (%fps% * 2)) * %height% / 2160 + +set /A keyfps=%fps%*%keyframes% + +echo.&cls +echo - - - - - Timelapse Creator by Jan Weigang - - - - - +echo. +echo Settings: +echo. +echo Codec: %codec% +echo Dimensions: %width% x %height% p %fps% +echo Bitrate: %bitrate% Mbit + + +Rem |---- Video Creation ----| + +:full + +echo. +echo. +echo Creating %codec% %height%p video with %fps% fps... +echo. + +if %codec% EQU prores ( + ffmpeg.exe ^ + -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt yuv422p10le ^ + -c:v %codec% -profile:v 2 -alpha_bits 0 -loglevel error -stats ^ + -filter:v "crop=%width%:%height%:exact=1,setsar=1,deflicker=%deflicker%%motion%"^ + "%dirfull%\%name%%codec%_%fps%%motionname%%deflickername%.mov" +) + +if %codec% EQU h264 ( + ffmpeg.exe ^ + -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt yuv420p ^ + -c:v libx264 -quality good -g %keyfps% -b:v %bitrate%M -loglevel error -stats ^ + -filter:v "crop=%width%:%height%:exact=1,setsar=1,deflicker=%deflicker%%motion%"^ + "%dirfull%\%name%%codec%_%fps%%motionname%%deflickername%.mov" +) + +if %codec% EQU h265 ( + ffmpeg.exe ^ + -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt yuv420p ^ + -c:v libx265 -quality good -g %keyfps% -b:v %bitrate%M -loglevel error -stats ^ + -x265-params log-level=error ^ + -filter:v "crop=%width%:%height%:exact=1,setsar=1,deflicker=%deflicker%%motion%"^ + "%dirfull%\%name%%codec%_%fps%%motionname%%deflickername%.mov" +) + +echo Done. + +:proxy + +if %proxytoggle% EQU off goto end + +echo. +echo. + +if %codec% EQU prores ( + echo Creating %codec% 720p proxy with %fps% fps... + echo. + + ffmpeg.exe ^ + -i %name%%%04d.%imagetype% -s 1280x720 -pix_fmt yuv422p10le -framerate %fps% ^ + -c:v %codec% -profile:v 2 -alpha_bits 0 -loglevel error -stats ^ + -filter:v "crop=1280:720:exact=1,setsar=1,deflicker=%deflicker%"^ + "%dirproxy%\%name%%codec%_%fps%%deflickername%.mov" +) + +if %codec% EQU prores echo Done. + +goto end + +Rem ------------------------------ + + + +Rem |---- GIF Creation ----| + +:processgifs + +echo. +echo. +echo Creating Full Length GIF... +echo. + +ffmpeg.exe -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt rgb8 -c:v gif ^ + -loglevel error -stats ^ + "%dirgifs%\%name%%height%p%fps%_full.gif" + +echo Done. + +echo. +echo. +echo Creating Short GIF (15MB)... +echo. + +ffmpeg.exe -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt rgb8 -c:v gif -fs %maxsize%M ^ + -loglevel error -stats ^ + "%dirgifs%\%name%%height%p%fps%_short.gif" + +echo Done. + +echo. +echo. + +goto end + +Rem ------------------------------ + + + +:end + +echo. +echo. + +if %ERRORLEVEL% NEQ 0 ( + echo Found an error and paused. + pause +) + + +echo. +echo Finished. +timeout /t 5 + + + +endlocal