Nethence Newdoc Olddoc Lab Your IP BBDock  

Transcoding a DVD to an MKV on Ubuntu

Introduction

It takes some time to transcode e.g. for a 3.5GB VOB file that contains a 01:16 hour duration video, processing with an AMD Athlon™ II X3 455 Processor (@3,30Ghz),

Preparation

Make sure those are installed,

dpkg -l mplayer mencoder ogmtools vorbis-tools x264 ffmpeg transcode
#libvo-aacenc0 libvo-aacenc-dev
#libavcodec-extra

Make sure FFmpeg is x264, VP8 & libvorbis capable,

ffmpeg -codecs 2>&1| grep -i vp8
ffmpeg -codecs 2>&1| grep -i x264
ffmpeg -codecs 2>&1| grep -i vorbis

Look at what presets you got for e.g. x264,

ffmpeg -f lavfi -i nullsrc -c:v libx264 -preset help -f mp4 - 2>&1 | grep Possible

Find out which title number, audio stream and subtitles you wanna RIP from the DVD,

#mplayer -nocache dvdnav://
#mplayer dvd://
mplayer dvd://3
ffmpeg -i /dev/dvd

Note. against an image e.g. add,

mplayer -dvd-device ../file.iso dvd://3

if that’s a protected DVD you might have to install that (two step process),

sudo apt install libdvd-pkg regionset
sudo dpkg-reconfigure libdvd-pkg

RIP the title

e.g. to RIP title 3,

dvdxchap -t 3 /dev/dvd > chapters.txt
time mplayer -dvd-device iso_or_dvd -dumpstream dvd://3 -dumpfile video.vob
#time mplayer -nocache -dumpstream dvdnav://3 -dumpfile video.vob

Prepare audio/video sync

Find out which streams you want,

ffmpeg -i video.vob

Find out about the delays (look at diff between video PTS & audio PTS),

tcprobe -i video.vob

if there is a difference, you might have to play with -itsoffset and it may become painful.

Then proceed with the transcoding, preferably in a gnu/screen session (so you don’t loose the terminal in case anything goes wrong with your graphical user interface). Here with video no-preset and audio vorbis quality 6,

screen
time ffmpeg -i video.vob -acodec libvorbis -aq 6 -vcodec libx264 video.mkv
#time ffmpeg -i video.vob -acodec libvorbis -aq 6 -vcodec libx264 -preset ultrafast videoufast.mkv
#time ffmpeg -i video.vob -acodec libvorbis -aq 6 -vcodec libx264 -preset veryslow videovslow.mkv

References

Trash

If there is no difference, proceed with the transcoding (first -map points to the video stream and second -map points to the audio stream),

ffmpeg -i video.vob -threads 0 -map 0.0 -map 0.1 -sn -vcodec libx264 -vpre veryslow -crf 20 -acodec libvorbis -ac 2 -aq 4 final.mkv

If e.g. video is 0.1 and audio is 1.1, you need to add -1 offset to the ffmpeg command line,

ffmpeg -i video.vob -itsoffset -1 -i video.vob -map 1.0 -map 0.1 -sn -vcodec libx264 -vpre veryslow -crf 20 -acodec libvorbis -ac 2 -aq 4 final.mkv

Note. libvo-aacenc / libvo_aacenc nor even libfdk-aac / libfdk_aac are available on ubuntu-provided ffmpeg so I’m using libvorbis for the MKV.

#time ffmpeg -i video.vob -an -vcodec libx264 -pass 1 -preset veryslow -threads 0 -b 3000k -x264opts frameref=15:fast_pskip=0 -f rawvideo -y /dev/null


#time ffmpeg -i video.vob -acodec libvo-aacenc -ab 256k -ar 96000 -vcodec libx264 -pass 2 -preset veryslow -threads 0 -b 3000k -x264opts frameref=15:fast_pskip=0 video.mkv

#time ffmpeg -i video.vob -acodec libvorbis -aq 6 -vcodec libx264 -pass 2 -preset veryslow -threads 0 -b 3000k -x264opts frameref=15:fast_pskip=0 video.mkv


ffmpeg -i video.vob -vcodec libvpx -crf 10 -acodec libvorbis -aq 6 video.webm

Proceed with a two pass transcoding to x264 & AAC,

date; time ffmpeg -i video.vob -an -vcodec libx264 -pass 1 -preset veryslow -threads 0 -crf 20 -f rawvideo -y /dev/null; date
ls -lhF ffmpeg2pass*log*
date; time ffmpeg -i video.vob -acodec libvorbis -aq 6 -vcodec libx264 -pass 2 -preset veryslow -threads 0 video.mkv; date

Home | GitHub | Donate