How to convert MKV to AVI using MEncoder
MEncoder actually is able to decode MKV (Matroska). However, I encounter some strange problem regarding the conversion of MKV to AVI using 1 pass encoding. The error message looks like below.
Too many audio packets in the buffer: (4096 in 8255101 bytes). Maybe you are playing a non-interleaved stream/file or the codec failed? For AVI files, try to force non-interleaved mode with the -ni option.
Unfortunately, my video is not AVI files. Anyway, there is a workaround for this problem.
The problem seems to cause by audio decoder for MKV or probably Ogg Vorbis. So the easiest solution is to extract audio stream first then multiplex that audio stream to a new AVI file. Follow me.
-
Extract the uncompressed audio stream to
audio.wav
.mplayer input.mkv -ao pcm:fast:file=audio.wav -vc null -vo null
-
Encode AVI using mencoder as usual plus
-audiofile audio.wav
.mencoder input.mkv \ -ffourcc divx \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=400 \ -audiofile audio.wav \ -oac mp3lame -lameopts vbr=3 \ -o output.avi
-
Remove the intermediate file
audio.wav
.rm -f audio.wav
As a result, I wrote a simple shell script to automate above steps.
#!/bin/sh INPUT=$1 OUTPUT=$2 mplayer "$INPUT" -ao pcm:fast:file=audio.wav -vc null -vo null mencoder "$INPUT" \ -ffourcc divx \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=400 \ -audiofile audio.wav \ -oac mp3lame -lameopts vbr=3 \ -slang eng \ -sws 2 -vf scale=352:-3 \ -o "$OUTPUT" rm -f audio.wav
In order to convert input.mkv to output.avi, run below command.
mkv2avi input.mkv output.avi
Note that the script also rescales the video to at most 352 by width. I found this tip at 1 and 2.
- sugree's blog
- 69709 reads
why rescale the output? Is
reduce size
I rescale the output to reduce the output file size. If you don't want to resize, just simply ignore
-sws 2 -vf scale=352:-3
.MKV to AVI Converter can do this
Nothing better than free software
alltoavi
Thank-you, it works fine,
You're the man
Nice one
Most excellent!
AlltoAVI has a horrible UI
Post new comment