Wani-Translation-Kit/wanilogo/Convert Alt Logo frames to ...

109 lines
3.8 KiB
Batchfile
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
:: Sets the variables for what charcteristics your frames are. You shouldn't need to mess with LOGO_FRAMERATE, but if your
:: frame names are different from say, CSP's (Where the default naming scheme isn't 'Timeline 1_XXXX'), this is where you change
:: them. LOGO_FRAME_DIGITS refers to how many digits at the end of the base frame name are in a collection, so for instance CSP's
:: goes from 0000 - 9999, which is 4 digits.
set "LOGO_FRAME_RATE=30"
set "LOGO_FRAME_STARTING_NUMBER=0"
set "LOGO_FRAME_BASENAME=Timeline 1_"
set "LOGO_FRAME_DIGITS=4"
set "LOGO_FRAME_EXTENSION=.png"
:: Set this to TRUE if you want to shrink it down
set "LOGO_FRAME_HALFRES=FALSE"
:: The filepaths for the frame and video folders
:: This will end up with a filepath like "logo_frames\\Timeline 1_0000.png" for frames
set "LOGO_PATH_FRAMES=logoalt_frames\\%LOGO_FRAME_BASENAME%%%0%LOGO_FRAME_DIGITS%d%LOGO_FRAME_EXTENSION%"
set "LOGO_PATH_VIDEO_LOSSLESS=export_lossless\\titlealt lossless.mp4"
set "LOGO_PATH_VIDEO_MASK_LOSSLESS=export_lossless\\titlealtmask lossless.mp4"
set "LOGO_PATH_VIDEO_GAME=export_game\\anim_logoalt1.webm"
set "LOGO_PATH_VIDEO_MASK_GAME=export_game\\anim_logoaltmask.mp4"
:: Set the command for scaling the video down half res
if "%LOGO_FRAME_HALFRES%"=="TRUE" (set "LOGO_HALFRES_COMMAND=scale=iw/2:ih/2")
if "%LOGO_FRAME_HALFRES%"=="FALSE" (set "LOGO_HALFRES_COMMAND=scale=iw:ih")
:: First we make the RGB video of the logo in lossless format, so it (on paper) should be pixel accurate to the frames.
if exist "%LOGO_PATH_VIDEO_LOSSLESS%" del "%LOGO_PATH_VIDEO_LOSSLESS%"
ffmpeg ^
-framerate %LOGO_FRAME_RATE% ^
-start_number %LOGO_FRAME_STARTING_NUMBER% ^
-i "%LOGO_PATH_FRAMES%" ^
-c:v libx264 -pix_fmt yuv444p -colorspace bt709 -crf 0 ^
-filter:v %LOGO_HALFRES_COMMAND% ^
"%LOGO_PATH_VIDEO_LOSSLESS%"
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1Done converting logo mask to lossless video.
:: Then we do it again, but make an alpha mask video out of those frames
if exist "%LOGO_PATH_VIDEO_MASK_LOSSLESS%" del "%LOGO_PATH_VIDEO_MASK_LOSSLESS%"
ffmpeg ^
-framerate %LOGO_FRAME_RATE% ^
-start_number %LOGO_FRAME_STARTING_NUMBER% ^
-i "%LOGO_PATH_FRAMES%" ^
-c:v libx264 -pix_fmt yuv444p -colorspace bt709 -crf 0 ^
-filter:v "alphaextract, %LOGO_HALFRES_COMMAND%" ^
"%LOGO_PATH_VIDEO_MASK_LOSSLESS%"
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1Done converting logo mask to lossless video.
:: Now we convert those lossless videos to game-usable videos
if exist "%LOGO_PATH_VIDEO_GAME%" del "%LOGO_PATH_VIDEO_GAME%"
ffmpeg ^
-i "%LOGO_PATH_VIDEO_LOSSLESS%" ^
-pix_fmt yuv420p10le -c:v vp9 -deadline good -cpu-used 0 -row-mt 1 -tile-columns 2 -lag-in-frames 25 -keyint_min 240 -auto-alt-ref 6 -arnr-maxframes 12 -enable-tpl 1 -colorspace bt709 -b:v 0 -crf 31 ^
"%LOGO_PATH_VIDEO_GAME%"
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1Done converting logo to game usable video.
:: And again for the mask
if exist "%LOGO_PATH_VIDEO_MASK_GAME%" del "%LOGO_PATH_VIDEO_MASK_GAME%"
ffmpeg ^
-i "%LOGO_PATH_VIDEO_MASK_LOSSLESS%" ^
-c:v mpeg4 -colorspace bt709 -qscale:v 10 -an ^
"%LOGO_PATH_VIDEO_MASK_GAME%"
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1Done converting logo mask to game usable video.
:: Rename the files to webm for Ren'Py. FFMPEG won't allow you to just specifiy a .webm on an mpeg4 file
if exist "export_game\\anim_logoaltmask.webm" del "export_game\\anim_logoaltmask.webm"
ren "%LOGO_PATH_VIDEO_MASK_GAME%" "anim_logoaltmask.webm"
echo %~n1Successfully changed extension of game-usable videos.
goto:end
:error

echo There was an error. Please check your input files or your FFMPEG isn't in this folder/not part of your environment variables.
pause
exit 0
:end

echo Encoding succesful.
pause
exit 0