Sunday, 5 July 2009

Tip of the Day: Convert MKV to AVI Using mencoder

This is useful when you need to convert some high resolution MKV video into an AVI file, in order to save space at the cost of quality. Say you have a Matroska video file, my_video.mkv. To convert it to AVI you can use mencoder (the command below is only one line):

mencoder my_video.mkv -ffourcc xvid -ovc lavc -lavcopts vcodec=xvid:vhq:vbitrate=1800 -oac mp3lame -lameopts vbr=5 -o output_video.avi

The resulted AVI file will be output_video.avi, located in the same directory as the source, and will have about 35% the size of the source file.

8 comments:

Anonymous said...

Don't work for me, it say that I have not the xvid codec and I have it

Bob D. said...

This does not work, just simply use this:

mencoder test.mkv -ovc lavc -lavcopts vcodec=mpeg4:threads=8:vbitrate=3000 -oac copy -o test.avi
ffmpeg -i test.avi -vcodec copy -vtag xvid -acodec copy final.avi

Anonymous said...

Avi and mkv are actually container formats. The file size savings come from converting a high quality h264-video-stream (most common video-format in mkv-files) into lower quality divx-streams. Of course, it wouldn't save any space if the original video-bitrate is 1800kbps. To save space you could also convert it into a 1800 kbps-h264-mkv-file.

juanes said...

Gracias a ustedes pude convertir el video, aunque me funcionó la solución de Bob.

http://tambienenlinux.wordpress.com/2010/04/18/convertir-mkv-a-avi/

Anonymous said...

Bob D.solution worked for me.

Roberto said...

I would like to thank Bob D. for the tip.

It worked almost flawlessly for me, I just had to change the mencoder option from "-oac copy" to "-oac pcm" because I got this error message : "Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it".

Martin Thoma said...

I used:

mencoder "Original.mkv" -ffourcc divx -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=400 -oac mp3lame -lameopts vbr=3 -o "New.avi"

Source with many other conversations.

Vivix said...

mencoder Vídeos/127.Hours.2010.SWESUB.AC3.720p.BluRay.x264-NaXii/127.Hours.2010.SWESUB.AC3.720p.BluRay.x264-NaXii.mkv -ffourcc xvid -ovc lavc -lavcopts vcodec=xvid:vhq:vbitrate=1800 -oac mp3lame -lameopts vbr=5 -o output_video.avi
MEncoder SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
success: format: 0 data: 0x0 - 0x16fc111a
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_DTS), -aid 0, -alang und
[mkv] Track ID 3: subtitles (S_TEXT/UTF8), -sid 0, -slang swe
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO: [avc1] 1280x688 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:31 fourcc:0x31637661 size:1280x688 fps:23.976 ftime:=0.0417
==========================================================================
Opening audio decoder: [libdca] DTS decoding with libdca
Stream with high frequencies VQ coding
AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
Selected audio codec: [dts] afm: libdca (DTS-libdca)
==========================================================================
Cannot find codec 'xvid' in libavcodec...
Couldn't open video filter 'lavc'.
Failed to open the encoder.

Exiting...