To convert an MKV to AVI, I do two things. The first thing I do is this:

ffmpeg -i filename.mkv -vcodec copy -acodec copy output.avi

or this:

ffmpeg -i filename.mkv -sameq -acodec copy output.avi

Either of these will convert the MKV to an AVI, but the problem is that the video does not play smoothly for some reason. That's fine though, because if I do one more thing it gets fixed:

ffmpeg -i output.avi -vcodec mpeg4 -b 4000k -acodec mp2 -ab 320k converted.avi

After I do this then the file plays without problem. I had success doing it this way for one file, but then I tried it on another file, and there is a slight, but noticeable loss in video quality. This is the output I get when doing the second step:

FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers
  built on Dec 29 2010 18:02:10 with gcc 4.2.1 (Apple Inc. build 5664)
  configuration: 
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0.11. 0 /  0.11. 0

Seems stream 0 codec frame rate differs from container frame rate: 359.00 (359/1) -> 29.92 (359/12)
Input #0, avi, from 'output.avi':
  Metadata:
    ISFT            : Lavf52.64.2
  Duration: 00:04:17.21, start: 0.000000, bitrate: 3074 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 704x480 [PAR 229:189 DAR 5038:2835], 29.92 fps, 29.92 tbr, 29.92 tbn, 359 tbc
    Stream #0.1: Audio: vorbis, 48000 Hz, stereo, s16
Output #0, avi, to 'converted.avi':
  Metadata:
    ISFT            : Lavf52.64.2
    Stream #0.0: Video: mpeg4, yuv420p, 704x480 [PAR 229:189 DAR 5038:2835], q=2-31, 4000 kb/s, 29.92 tbn, 29.92 tbc
    Stream #0.1: Audio: mp2, 48000 Hz, stereo, s16, 320 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1

I just used arbitrarily large settings on the second step and it worked nicely before but not in this case. What settings should I use?

link|improve this question

74% accept rate
feedback

2 Answers

up vote 2 down vote accepted

try ffmpeg -i filename.mkv -vcodec copy -acodec copy -g 1 output.avi
another option ffmpeg -i filename.mkv -sameq -acodec copy -g 1 output.avi

edit: moving a comment into the answer for a check

then try substituting -sameq or -g1 in the second step for the video parameters

link|improve this answer
1  
then try substituting -sameq or -g1 in the second step for the video parameters – aking1012 Dec 30 '10 at 16:59
I tried both of those and the playback of the output file is still jerky. A second conversion is still necessary. – OSX NINJA Dec 30 '10 at 16:59
Substituting -sameq for -vcodec mpeg4 -b 4000k fixed the problem. Do you know why it is necessary to do this in two steps for it to work? – OSX NINJA Dec 30 '10 at 17:07
1  
free software has lots of oddities. I would think it is an issue with which operation it performs first, container parsing then stream parsing, container encoding then stream encoding. Just my guess. When you do it in two steps you force the order of operations to be stream encoding then container encoding. – aking1012 Dec 30 '10 at 17:16
feedback

May I recommend a shortcut I use regularly?

ffmpeg -i filename.mkv -sameq output.avi
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.