Skip to content

Instantly share code, notes, and snippets.

@hjst
Last active April 21, 2017 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjst/561f665eb0cea18f45809a20185a2336 to your computer and use it in GitHub Desktop.
Save hjst/561f665eb0cea18f45809a20185a2336 to your computer and use it in GitHub Desktop.
Reencode .VOB files from an old DVD to .mp4 files of reasonable size
# Based on the two-pass suggestions here: https://trac.ffmpeg.org/wiki/Encode/H.264
#
# Optional: for multiple VOB files you wish to concatenate, do so *before* reencoding:
ffmpeg -i "concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB" -c copy CONCAT.VOB
# The target average bitrate (for -b:v switch) is calculated like so:
# For a video that's 600 seconds long and a target filesize of 200MB
# (200 MiB * 8192 [converts MiB to kBit]) / 600 seconds = ~2730 kBit/s total bitrate
# 2730 - 128 kBit/s (desired audio bitrate) = 2602 kBit/s video bitrate
#
# Options are as follows:
# -preset slow # not actually slow with a half-way decent CPU; trades speed for smaller output size
# -b:v 2500k # see calculation above
# -profile:v high -level 4.2 # don't care about old playback device compatibility
# -tune film # use "grain" if grain preservation is important, "animation" if animated
# -filter:v yadif # deinterlace filter (probably needed for old DVD sources)
# -c:a aac -b:a 128k # 128k AAC audio (fine for lossy transfers of old DVDs)
# -f mp4 /dev/null # use mp4 as output format but don't write a file for the first pass
ffmpeg -y -i VTS_01_2.VOB -c:v libx264 \
-preset slow \
-b:v 2100k \
-profile:v high -level 4.2 \
-tune film \
-filter:v yadif \
-pass 1 \
-c:a aac -b:a 128k \
-f mp4 /dev/null && \
ffmpeg -i VTS_01_2.VOB -c:v libx264 \
-preset slow \
-b:v 2100k \
-profile:v high -level 4.2 \
-tune film \
-filter:v yadif \
-pass 2 \
-c:a aac -b:a 128k \
VTS_01_2.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment