Sunday, November 25, 2007

MKV to AVI under Linux

You need:
MKVtoolnix


1. MKV is a container, to see what the file contains:
$ mkvinfo movie.mkv
Ex:
+ EBML head
|+ Doc type: matroska
|+ Doc type version: 1
|+ Doc type read version: 1
+ Segment, size 736993124
|+ Seek head (subentries will be skipped)
|+ EbmlVoid (size: 4027)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libebml v0.7.3 + libmatroska v0.7.4
| + Writing application: mkvmerge v1.0 ('Soul Food To Go') built on Nov 17 2004 15:06:35
| + Duration: 3682.987s (01:01:22.987000000)
| + Date: Wed Dec 8 15:42:45 2004 UTC
| + Title: Il Coraggioso - The Brave
| + Segment UID: 0x84 0xad 0xc1 0x0b 0x8e 0x9b 0x06 0x84 0xef 0x2a 0xf9 0xa6 0xf4 0x94 0x07 0x5d
| + Next segment UID: 0xeb 0x46 0x75 0xb4 0x7a 0x71 0xc2 0x7f 0xc7 0x36 0x44 0x06 0x9b 0xe4 0x90 0x76
|+ Segment tracks
| + A track
| + Track number: 1
| + Track UID: 38700354
| + Track type: video
| + Default flag: 1
| + Lacing flag: 0
| + MinCache: 1
| + Timecode scale: 1.000000
| + Codec ID: V_MS/VFW/FOURCC
| + CodecPrivate, length 40 (FourCC: XVID, 0x44495658)
| + Default duration: 40.000ms (25.000 fps for a video track)
| + Language: und
| + Name: Il Coraggioso - the Brave
| + Video track
| + Pixel width: 608
| + Pixel height: 336
| + Display width: 608
| + Display height: 336
| + A track
| + Track number: 2
| + Track UID: 3348909422
| + Track type: audio
| + Default flag: 1
| + Lacing flag: 1
| + MinCache: 0
| + Timecode scale: 1.000000
| + Codec ID: A_AAC/MPEG2/LC/SBR
| + Default duration: 42.667ms (23.438 fps for a video track)
| + Language: ita
| + Name: Ita aac 5.1
| + Audio track
| + Sampling frequency: 24000.000000
| + Channels: 6
| + Output sampling frequency: 48000.000000
|+ EbmlVoid (size: 1024)
|+ Cluster

2. select the numbers of the trucks you want to extract and type:
$ mkvextract tracks "/mnt/common/Film/movie.mkv" 1:/mnt/common/Film/movie.avi 2:/mnt/common/Film/movie.aac

3. If the audio file has the aac format you need also:
faad
lame

4. To convert the file audio in mp3 format:
$ faad -d /mnt/common/Film/movie.aac
$ lame /mnt/common/Film/movie.wav


5. Let's put all toghether:
$ mencoder -audiofile movie.wav.mp3 -oac mp3lame -ovc copy movie.avi -o movie_complete.avi

3 comments:

catch said...

Thanks for the tip! It eases my job now.

Anonymous said...

Not always quite as simple as that. See this article for more complex operations:
http://juliensimon.blogspot.com/2009/01/howto-converting-mkv-files-to-play-on.html

Anonymous said...

My friend and I were recently discussing about the prevalence of technology in our day to day lives. Reading this post makes me think back to that debate we had, and just how inseparable from electronics we have all become.


I don't mean this in a bad way, of course! Societal concerns aside... I just hope that as the price of memory falls, the possibility of transferring our brains onto a digital medium becomes a true reality. It's one of the things I really wish I could see in my lifetime.


(Posted on Nintendo DS running [url=http://kwstar88.zoomshare.com/2.shtml]R4i SDHC[/url] DS FFV2)