Quantcast
Channel: Anders Lundgren » Computers
Viewing all articles
Browse latest Browse all 10

ISO to MKV in Linux

$
0
0

First mount the ISO-file:
# mkdir /mnt/dvdiso
# mount -o loop -t iso9660 my.iso /mnt/dvdiso/

Now, to get some information about the media in the ISO-file:

$ mplayer -dvd-device /mnt/dvdiso/ dvd://0 -vo null -ao null
[...]
audio stream: 0 format: ac3 (stereo) language: en aid: 128.
[...]
subtitle ( sid ): 0 language: sv
subtitle ( sid ): 1 language: no
subtitle ( sid ): 2 language: da
subtitle ( sid ): 3 language: fi
subtitle ( sid ): 4 language: is
[...]

Also get the length of the titles:

$ mplayer -dvd-device /mnt/dvdiso/ dvd://0 -identify -frames 0 -vo null -ao null
[...]
ID_DVD_TITLE_1_LENGTH=6113.000
ID_DVD_TITLE_2_LENGTH=0.480
[...]

Find the track you want to rip and run this. If you haven’t found your track you can simply try to run this command for all tracks, your track is most likely the one that generates the largest .vob file.

$ mplayer -dvd-device /mnt/dvdiso/ dvd://1 -dumpstream -dumpfile movie.vob

Copy the IFO file for the track, for the track above thats vts_01_0.ifo.

$ cp /mnt/dvdiso/video_ts/vts_01_0.ifo .

Get the chapter list:

dvdxchap -t 1 /mnt/dvdiso/ > chapters.txt

Now, get all the subtitles:

$ tccat -i movie.vob | tcextract -x ps1 -t vob -a 0x20 > subs-0
$ tccat -i movie.vob | tcextract -x ps1 -t vob -a 0x21 > subs-1
$ tccat -i movie.vob | tcextract -x ps1 -t vob -a 0x22 > subs-2
$ tccat -i movie.vob | tcextract -x ps1 -t vob -a 0x23 > subs-3
$ tccat -i movie.vob | tcextract -x ps1 -t vob -a 0x24 > subs-4
$ subtitle2vobsub -o vobsubs -i vts_01_0.ifo -a 0 $ subtitle2vobsub -o vobsubs -i vts_01_0.ifo -a 1 $ subtitle2vobsub -o vobsubs -i vts_01_0.ifo -a 2 $ subtitle2vobsub -o vobsubs -i vts_01_0.ifo -a 3 $ subtitle2vobsub -o vobsubs -i vts_01_0.ifo -a 4

Now, rip the audio using the AID we got from mplayer earlier:

$ mplayer movie.vob -aid 128 -dumpaudio -dumpfile audio128.ac3

To determine cropping parameters automatically, run:

$ mplayer movie.vob -vf cropdetect -sb 50000000 -vo null -ao null

Record the detected cropping parameters (for example 704:480:10:48).

An excellent bitrate calculator that suits our need can be found at Marc Rintsch's homepage. (direct link.) Extract bitrate.py from the downloaded tar file and run it:

$ ./bitrate.py -o 0.5 -t 1400 1:42:04 audio128.ac3 vobsubs.idx vobsubs.sub
Length: 6124 seconds (153100 frames @ 25.0 fps)
Other: 160.44 MB @ 219.8 kbit/s
Target: 1400 MB => 1239.6 MB @ 1689.5 kbit/s

Now encode in two passes, run this for pass 1:

$ mencoder movie.vob -vf pullup,softskip,crop=704:480:10:48,harddup -oac copy -ovc x264 -x264encopts bitrate=1690:subq=5:bframes=3:b_pyramid:weight_b:turbo=1:threads=auto:pass=1 -ofps 25 -o /dev/null

And then this for pass 2:

mencoder movie.vob -vf pullup,softskip,crop=704:480:10:48,harddup -oac copy -ovc x264 -x264encopts bitrate=1690:subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:threads=auto:pass=2 -o movie.264

Finally you merge everything together like this:

mkvmerge --title "My move" -o movie.mkv --chapters chapters.txt --default-duration 0:25fps -A movie.264 audio128.ac3 vobsubs.idx


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images