Last active
January 15, 2026 18:21
-
-
Save deltqz/519675376392be927ab7b32041101da0 to your computer and use it in GitHub Desktop.
muxDVD - Easy DVD remuxing with FFmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a" | |
| :SART | |
| title muxDVD | |
| echo %ESC%[91mmuxDVD - FFmpeg DVD remuxer%ESC%[0m | |
| echo. | |
| :: Clear previous loop variables | |
| set "TITLE=" | |
| set "CHAPTER_START=" | |
| set "CHAPTER_END=" | |
| set "OUTPUT_FILE=" | |
| set "AUDIO_CODEC=" | |
| set "AUDIO_PARAMS=" | |
| if "%~1"=="" ( | |
| set /p INPUT_PATH="%ESC%[96mInput: %ESC%[0m" | |
| ) else ( | |
| set "INPUT_PATH=%~1" | |
| echo %ESC%[96mInput: %ESC%[0m%~1 | |
| shift | |
| ) | |
| set /p TITLE="%ESC%[96mTitle number: %ESC%[0m" | |
| set /p CHAPTER_START="%ESC%[96mFirst chapter: %ESC%[0m" | |
| set /p CHAPTER_END="%ESC%[96mLast chapter: %ESC%[0m" | |
| set /p OUTPUT_FILE="%ESC%[96mOutput filename: %ESC%[0m" | |
| if "%OUTPUT_FILE%"=="" set "OUTPUT_FILE=output" | |
| if /I NOT "%OUTPUT_FILE:~-4%"==".mkv" set "OUTPUT_FILE=%OUTPUT_FILE%.mkv" | |
| echo. | |
| echo Analyzing audio codec... | |
| for /f "tokens=*" %%a in ('ffprobe -v quiet -f dvdvideo -preindex True -title %TITLE% -select_streams a:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%INPUT_PATH%"') do set "AUDIO_CODEC=%%a" | |
| if "%AUDIO_CODEC%"=="" goto :ERROR_NO_CODEC | |
| echo Detected audio codec: %AUDIO_CODEC% | |
| echo "%AUDIO_CODEC%" | findstr /i "pcm" >nul | |
| if %errorlevel%==0 goto :ENCODE_FLAC | |
| :COPY_AUDIO | |
| echo Audio is not PCM (%AUDIO_CODEC%). Copying audio stream. | |
| set "AUDIO_PARAMS=-c:a copy" | |
| goto :REMUX | |
| :ENCODE_FLAC | |
| echo Audio is PCM. Encoding to FLAC. | |
| set "AUDIO_PARAMS=-c:a flac -compression_level:a 8" | |
| goto :REMUX | |
| :REMUX | |
| echo. | |
| echo Remuxing file... | |
| ffmpeg -hide_banner -v quiet -f dvdvideo -preindex True -title %TITLE% -chapter_start %CHAPTER_START% -chapter_end %CHAPTER_END% -i "%INPUT_PATH%" -map 0 -c copy %AUDIO_PARAMS% "%OUTPUT_FILE%" | |
| echo Process finished. | |
| pause | |
| cls | |
| goto :SART | |
| :ERROR_NO_CODEC | |
| echo ERROR: No audio codec detected. Check if ffprobe is in your PATH and input is valid. | |
| pause | |
| exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment