Advertisement
_moelle

dynamic AERENDER MP4/PNG + WEBM/WEBP convert

Nov 22nd, 2023
1,688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3.  
  4. set "scriptPath=%~dp0"
  5. set "Folder=%scriptPath%"
  6. ::set "Folder=C:\data_driven_ae_template-1"
  7.  
  8. set "RenderedFolder=%Folder%\_rendered"
  9.  
  10. set "outputFolderWebm=%RenderedFolder%\_webm"
  11. set "outputFolderWebp=%RenderedFolder%\_webp"
  12.  
  13. REM Use all .aep files inside of the scripts location that use the prefix "comp_"
  14. REM ignore files that include blanks (spaces) in their names
  15. for %%i in (%Folder%\comp_*.aep) do (
  16.    echo %%i | findstr " " > nul
  17.       if errorlevel 1 (
  18.          for /f "delims=." %%a in ("%%~ni") do set "compName=%%a"
  19.             set "inputFile=%%i"
  20.             echo !inputFile!
  21.             echo !compName!
  22.             REM thumbnail-export of frame 0 as PNG
  23.             AERENDER -project "!inputFile!" -comp "!compName!" -s 0 -e 0 -RStemplate "Best Settings" -OMtemplate "PNG" -output "%Folder%\_rendered\!compName!_[#].png"
  24.             AERENDER -project "!inputFile!" -comp "!compName!_square" -s 0 -e 0 -RStemplate "Best Settings" -OMtemplate "PNG" -output "%Folder%\_rendered\!compName!_square_[#].png"
  25.             AERENDER -project "!inputFile!" -comp "!compName!_1920" -s 0 -e 0 -RStemplate "Best Settings" -OMtemplate "PNG" -output "%Folder%\_rendered\!compName!_1920_[#].png"
  26.             REM video-export as MP4
  27.             AERENDER -project "!inputFile!" -comp "!compName!" -RStemplate "Best Settings" -mp -continueOnMissingFootage -mem_usage "100" "100" -OMtemplate "MP4" -output "%Folder%\_rendered\!compName!.mp4"
  28.             AERENDER -project "!inputFile!" -comp "!compName!_square" -RStemplate "Best Settings" -mp -continueOnMissingFootage -mem_usage "100" "100" -OMtemplate "MP4" -output "%Folder%\_rendered\!compName!_square.mp4"
  29.             AERENDER -project "!inputFile!" -comp "!compName!_1920" -RStemplate "Best Settings" -mp -continueOnMissingFootage -mem_usage "100" "100" -OMtemplate "MP4" -output "%Folder%\_rendered\!compName!_1920.mp4"
  30.       )
  31. )
  32. REM create output folders for webp and webm if not existing
  33. if not exist "%outputFolderWebp%" mkdir "%outputFolderWebp%"
  34. if not exist "%outputFolderWebm%" mkdir "%outputFolderWebm%"
  35. REM webp conversion
  36. for %%i in (%RenderedFolder%\*.png) do (
  37.     set "inputFile=%%i"
  38.     echo Processing PNG: !inputFile!
  39.    
  40.     for /f "delims=." %%a in ("%%~ni") do (
  41.         set "name=%%a"
  42.         set "name=!name:~0,-2!"  
  43.        REM Strip the last two characters
  44.     )
  45.     echo !name!
  46.    
  47.     ffmpeg -i "!inputFile!" -y "%outputFolderWebp%\!name!.webp"
  48. )
  49. REM webm conversion
  50. for %%i in (%RenderedFolder%\*.mp4) do (
  51.     set "inputFile=%%i"
  52.     for /f "delims=." %%a in ("%%~ni") do set "name=%%a"
  53.     echo !name!
  54.     ffmpeg -i "!inputFile!" -y -c:v libvpx-vp9 -crf 28 -b:v 0 -b:a 128k -c:a libopus "%outputFolderWebm%\!name!.webm"
  55. )
  56.  
  57. echo Conversion complete.
  58. ::cmd /k
  59. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement