Skip to content

Instantly share code, notes, and snippets.

@andreasbotsikas
Last active August 2, 2024 13:56
Show Gist options
  • Save andreasbotsikas/8bad3df5309dd0383f2e2c450b22481c to your computer and use it in GitHub Desktop.
Save andreasbotsikas/8bad3df5309dd0383f2e2c450b22481c to your computer and use it in GitHub Desktop.
Convert DVD to mp4 using ffmpeg
REM Download ffmpeg from https://www.ffmpeg.org/download.html.
REM Place ffmpeg.exe in the folder with the vob files
REM Merge all vob files into one
REM VTS_01_0.VOB is usually the menu which you may not want
if exist VTS_01_7.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB+VTS_01_4.VOB+VTS_01_5.VOB+VTS_01_6.VOB+VTS_01_7.VOB ConCat.vob
) else if exist VTS_01_6.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB+VTS_01_4.VOB+VTS_01_5.VOB+VTS_01_6.VOB ConCat.vob
) else if exist VTS_01_5.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB+VTS_01_4.VOB+VTS_01_5.VOB ConCat.vob
) else if exist VTS_01_4.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB+VTS_01_4.VOB ConCat.vob
) else if exist VTS_01_3.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB ConCat.vob
) else if exist VTS_01_2.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB ConCat.vob
) else (
copy /b VTS_01_1.VOB ConCat.vob
)
REM Store the name of the folder
for %%I in (.) do set CurrDirName=%%~nxI
REM Convert that single vob into mp4
ffmpeg -loglevel warning -i "ConCat.vob" -codec:a copy -codec:v libx264 "%CurrDirName%.mp4"
REM I run into an issue with one DVD where audio was encoded with pcm_dvd
REM which is not supported by x264
REM Stream #0:2[0xa0]: Audio: pcm_dvd, 48000 Hz, stereo, s16, 1536 kb/s
REM To fix that, I encoded audio as well (instead of copy done above)
REM ffmpeg -i "ConCat.vob" -codec:a ac3 -codec:v libx264 "ConCat.mp4"
REM Wait for input to exit batch
pause
@andreasbotsikas
Copy link
Author

@jmb-2022 I was converting old personal dvds, so I didn't have any subtitles. It seems that ffmpeg can export subtitles with something like:

ffmpeg -i concat:VTS_01_1.VOB\|VTS_01_2.VOB\|VTS_01_3.VOB\|VTS_01_4.VOB \
-map 0:0 -map 0:1 -map 0:2 -map 0:6 -map 0:5 -map 0:4 \
-c:v libx264 -preset fast -crf 18 \
-c:a copy -metadata:s:a:0 language=ger \
-c:a copy -metadata:s:a:1 language=eng \
-c:s copy -metadata:s:s:0 language=eng \
-c:s copy -metadata:s:s:1 language=ger \
-c:s copy -metadata:s:s:2 language=ger \
-f matroska movie.mkv 

Never tried it though. Feel free to reply with your solution.

@Hiroex
Copy link

Hiroex commented Sep 8, 2023

Your script works perfectly. One small thing I would like it to do is copy the timestamps as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment