Mercurial > codedump
comparison god.bat @ 103:1cc4f545a260
Add files via upload
committer: GitHub <noreply@github.com>
| author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
|---|---|
| date | Thu, 22 Sep 2022 00:01:37 -0400 |
| parents | |
| children | 2e115eb60be8 |
comparison
equal
deleted
inserted
replaced
| 102:eacdf8cc0335 | 103:1cc4f545a260 |
|---|---|
| 1 @echo off | |
| 2 | |
| 3 REM Welp, this was pointless. | |
| 4 REM | |
| 5 REM There's really no way to put raw PCM audio | |
| 6 REM in an MP4 container. MP4 is already a really | |
| 7 REM shitty format for a number of other reasons | |
| 8 REM (no real subtitle support, VERY limited codec | |
| 9 REM options, etc.), which is why I prefer using | |
| 10 REM Matroska for literally anything outside of | |
| 11 REM Vegas. | |
| 12 REM | |
| 13 REM However, I learned how to make an arguments | |
| 14 REM parser in fucking Batch out of all things, | |
| 15 REM so maybe there was a purpose for this after | |
| 16 REM all. | |
| 17 REM | |
| 18 REM TL;DR: I didn't even come close to solving the | |
| 19 REM problem this was meant to fix, and MP4 is a | |
| 20 REM godawful container. :D | |
| 21 | |
| 22 setlocal EnableDelayedExpansion | |
| 23 call :argparser %* | |
| 24 if %count% LSS 3 goto usage | |
| 25 REM mp4 barely supports flac, matroska ftw | |
| 26 REM | |
| 27 REM vegas pro sucks and has barely any support | |
| 28 REM for different codecs in MP4s (see: yuv 4:4:4), | |
| 29 REM and really *only* supports AAC. this sucks, | |
| 30 REM cause AAC can be a bitch at times | |
| 31 if not defined acodec set "acodec=flac" | |
| 32 | |
| 33 ffmpeg -y -i "!inputmp4!" -i "!inputwav!" -c:v copy -c:a !acodec! ^ | |
| 34 -strict -2 -loglevel quiet -stats "!outputmp4!" | |
| 35 goto cleanup | |
| 36 | |
| 37 :usage | |
| 38 echo.Usage: | |
| 39 echo. %~n0.bat ^<input.mp4^> ^<input.wav^> ^<output.mp4^> [--acodec ^<codec^>] | |
| 40 echo. [--debug] | |
| 41 echo. | |
| 42 echo.Arguments: | |
| 43 echo. ^<input.mp4^>: input mp4 with at least 1 video stream | |
| 44 echo. ^<input.wav^>: input wav (or flac) | |
| 45 echo. ^<output.mp4^>: output mp4 | |
| 46 echo. [--acodec ^<codec^>]: (optional) audio codec to use | |
| 47 echo. [--debug]: prints all commands to the terminal | |
| 48 echo. | |
| 49 REM we don't know if the user is running from a terminal or not... | |
| 50 echo.Press any key to exit... | |
| 51 pause 1>NUL 2>&1 | |
| 52 | |
| 53 :cleanup | |
| 54 REM this MIGHT fuck up someone's environment variables | |
| 55 REM i don't care :). deal with it | |
| 56 set "inputmp4=" | |
| 57 set "inputwav=" | |
| 58 set "outputmp4=" | |
| 59 set "acodec=" | |
| 60 set "count=" | |
| 61 exit /b 0 | |
| 62 | |
| 63 REM -------------- Functions -------------- | |
| 64 | |
| 65 :argparser | |
| 66 set "count=0" | |
| 67 :argparser_loop | |
| 68 if not "x%~1x" == "xx" ( | |
| 69 set "var=%~1" | |
| 70 if "!var:~0,2!"=="--" ( | |
| 71 if "!var!"=="--acodec" ( | |
| 72 shift | |
| 73 set "acodec=%~2" | |
| 74 goto :argparser_end | |
| 75 ) | |
| 76 if "!var!"=="--debug" ( | |
| 77 @echo on | |
| 78 goto :argparser_end | |
| 79 ) | |
| 80 ) else ( | |
| 81 if %count% EQU 0 set "inputmp4=%~1" | |
| 82 if %count% EQU 1 set "inputwav=%~1" | |
| 83 if %count% EQU 2 set "outputmp4=%~1" | |
| 84 set /a "count+=1" | |
| 85 ) | |
| 86 :argparser_end | |
| 87 shift | |
| 88 goto :argparser_loop | |
| 89 ) | |
| 90 set "var=" | |
| 91 exit /b 0 | |
| 92 | |
| 93 :error | |
| 94 echo [ERROR]: %~1 | |
| 95 exit /b 0 | |
| 96 | |
| 97 :warning | |
| 98 echo [WARNING]: %~1 | |
| 99 exit /b 0 | |
| 100 | |
| 101 :info | |
| 102 echo [INFO]: %~1 | |
| 103 exit /b 0 |
