Author Topic: Converting MKV to MP4 (Reencode) results in random frame rate  (Read 4501 times)

Zolaerla

  • Newbie
  • *
  • Posts: 4
Using AVIDemux v2.6.10 GUI in Windows 7 x64.

In case my system specs matter at all:
MoBo:     ASUS P8Z68 Deluxe/Gen3
Chipset:  Intel Z68 Express
CPU:      Intel i7-2600K LGA1155 (Quad Core 3.4Ghz)
Memory:   2x 8GB G.Skills DDR3 (16GB, 1666Mhz)
Video:    NVidia GeForce GTX 980Ti 6GB


I have been trying to translate some videos from ultra-high-bitrate XviD in .mkv format to H264 MP4 for final archival/storage. However, whenever I do, I get very random frame rates and dropped frames in the resulting file, so everything looks horribly stuttered. This happens if I use all default options for everything, or if I play with a lot of options. If I add a filter to change the frame rate to 29.98, it just looks really choppy with the final frame rate. The simple method is to just choose "H264 (ff/nvidia)" for Video Output, and "MP4 Muxer" or "MP4v2 Muxer" for Output Format. Audio makes no difference no matter what I use, or even if there is no audio.

This problem does not happen with the exact same video stream in AVI files. I can just use "Copy" for Video Output, then "AVI Muxer" for output format, create an AVI file, then load that AVI file and THEN convert to MP4, but since the first file I tried this on is 28.5GB in MKV, it seems excessive to have to go through this each time I want to convert a video. The video data doesn't change, but the end results do!

I have created an ultra-low res AVI and MKV that exhibit this behavior (the frame rate is the only concern at this time):
http://memso.com/Media/AVIDemux/Intro.avi - 1.11MB
http://memso.com/Media/AVIDemux/Intro.mkv - 1.09MB

This results in the following MP4 files as output:
From AVI: http://memso.com/Media/AVIDemux/Intro-avi.mp4 - 1.30MB
From MKV: http://memso.com/Media/AVIDemux/Intro-mkv.mp4 - 0.86MB (yes, very different size)

I have no idea why this is happening, or how to prevent having to do the extra step of converting to AVI. Is it possible to get the right frame rate from MKVs?

Thank you!

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6053
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #1 on: June 12, 2016, 05:51:33 AM »
- Don't use H264 (ff/nvidia)" use Mpeg4 AVC (x264), provide extra cooling for your computer case, if you have cold stone floor, put pc there.
- Try a with recent newer avidemux 2.6.12 win64 or win64_ffmpeg3.
http://www.avidemux.org/nightly/

Zolaerla

  • Newbie
  • *
  • Posts: 4
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #2 on: June 12, 2016, 06:56:44 PM »
I tried x264, far smaller file size, same frame rate problem:
http://memso.com/Media/AVIDemux/Intro-mkv-x264.mp4 - 0.31MB

I tried with the latest nightly, same exact file sizes (though different checksums) and same problem:
H264 (ff/nvidia): http://memso.com/Media/AVIDemux/Intro-mkv-nightly.mp4 - 0.31MB
Mpeg4 AVC (x264): http://memso.com/Media/AVIDemux/Intro-mkv-x264-nightly.mp4 - 0.86MB

My computer does not have any issues with overheating, so that isn't the problem. When I say "Random", I mean each video I have tried with reports a different frame rate, none of which look good, not that each time I encode the same file it is different.

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10974
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #3 on: June 12, 2016, 07:40:51 PM »
you might try adding "resample framerate" to make sure the number of image per sec stays constant
the mp4 muxer is half broken when dealing with varying framerate

Zolaerla

  • Newbie
  • *
  • Posts: 4
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #4 on: June 12, 2016, 08:49:52 PM »
you might try adding "resample framerate" to make sure the number of image per sec stays constant
the mp4 muxer is half broken when dealing with varying framerate

This does not fix anything. The file now reports the correct frame rate, but playing the video is still badly stuttered. Again, if I use the AVI as a source, this does not happen. It is ONLY from the MKV:

From MKV: http://memso.com/Media/AVIDemux/Intro-mkv-x264-fps.mp4 - 0.371MB - Shows 23.98fps, but stutters badly
From AVI: http://memso.com/Media/AVIDemux/Intro-avi-x264-fps.mp4 - 0.457MB - Shows 23.98fps and is actually smooth

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10974
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #5 on: June 13, 2016, 04:16:52 AM »
Avidemux detects inconsistent timing on the frame (going back and forth) so it drops a lot of them
Avi does not have timestamps so they are seen as correct

As of why, it seems the file is made using packed bframe for mkv, which is a VERY BAD idea

Packed bframes are detected for avi, and removed automatically


Zolaerla

  • Newbie
  • *
  • Posts: 4
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #6 on: June 13, 2016, 07:35:20 PM »
Though it hardly surprises me that MKVs created through VirtualDubMod have issues, what does surprise me is that various video players (WMP, MPC and VLC) have no issues playing the MKVs properly, yet AVIDemux cannot figure them out. In any case, it looks like there is no way to skip the added step. Thanks for looking into the problem for me.

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10974
Re: Converting MKV to MP4 (Reencode) results in random frame rate
« Reply #7 on: June 14, 2016, 08:18:23 AM »
Just saving it as avi and edit the avi will work indeed fine