Log in

View Full Version : MKV to MP4 Without quality Loss (Audio/Video Sync Issues)


Shinji-kun
23rd August 2010, 18:10
I am trying to remux a ~23 min. video (MKV container/AVC) to an easier to edit container, in order to cut a 3-5 minute clip from it and upload it to the internet.

So far I have tried:

- Opening the MKV in Avidemux and trying to save the 3 minute selection.

- Opening the mkv in Virtualdubmod w/ avisynth and trying to save the selection as an Xvid AVI.

- Extracting the contained files with MKVextractGUI and remuxing them to:
- an mp4 file with my mp4box gui.
- an mkv with just the single audio and subtitle files I wanted to be in the clip.


In every case the resulting video file experienced the same problem: severe audio/video sync problems. When I tried just opening the MKV file (in avidemux or vdm) to edit it directly, the audio was to late. When i tried remuxing it to an mp4, the audio was too far ahead of the video.

Whatever I try there is always the same problem with the audio/video being out of sync. I have tried other video forums, but the posters just go around in circles. The closest I've come to solving this issue is by remuxing the mkv to an mp4 in my mp4box gui. Although the audio and subtitles are completely synced, the video and audio are not.

This problem keeps recurring with all mkv/H264 files I attempt to convert or remux. I don't know whether the issue is with the laughable mkv support that is currently available or if my computer is just being hacked by some loser trying to screw up the conversion every single time, but MKV/H264 files are the only videos i've had trouble successfully converting and uploading to a streaming site.

So if anyone coudl give any advice that would actually solve this repeated problem, thanks in advance.

nm
23rd August 2010, 18:18
I am trying to remux a ~23 min. video (MKV container/AVC) to an easier to edit container, in order to cut a 3-5 minute clip from it and upload it to the internet.

Cut with mkvmerge --split or with mkvmerge GUI.

Shinji-kun
23rd August 2010, 19:02
Cut with mkvmerge --split or with mkvmerge GUI.

I tried checking the "enable splitting" box in the global tab in mkvmerge. I used the split by time code option, specified the exact durations, and it split the video into 3 files, the 2nd of which was the closest to the clip I wanted, but still the audio was out of sync. The cuts weren't even close enough to the durations I typed. Instead of the selection i wanted being contained entirely in the second video, the first half of the clip was at the end of the 2nd video and the remaining portion was at the beginning of the 3rd video. This, though, is clearly not what I was aiming to do.

b66pak
23rd August 2010, 19:48
make a .bat file like this:

mkvmerge -o my_video-part.mkv my_video.mkv --split 00:01:30 --split 00:03:45 --split-max-files 3

edit my_video.mkv with your file name and my_video-part.mkv with the desired final name.

also edit the beginning of the cut (00:01:30) and the end of the cut (00:03:45) in this format: HH:MM:SS (hours:minutes:seconds).

Your cut will be named my_video-part-002.mkv.

N.B. mkvmerge will cut the video at the first IDR frame AFTER the desired time!
_

Shinji-kun
23rd August 2010, 19:54
People, use coherent grammar.

b66pak
23rd August 2010, 19:58
excuse the speed...
_

Shinji-kun
23rd August 2010, 20:15
make a .bat file like this:

mkvmerge -o my_video-part.mkv my_video.mkv --split 00:01:30 --split 00:03:45 --split-max-files 3

edit my_video.mkv with your file name and my_video-part.mkv with the desired final name.

also edit the beginning of the cut (00:01:30) and the end of the cut (00:03:45) in this format: HH:MM:SS (hours:minutes:seconds).

Your cut will be named my_video-part-002.mkv.

N.B. mkvmerge will cut the video at the first IDR frame AFTER the desired time!
_

What do you mean? Do you mean to use time code for every single split or just broaden the start and end times for the selection that I want to cut.

The video is 23 minutes long. I want to cut a selection from 00:03:53 to 00:06:23. I assume the 2nd of the 3 mkv files should contain the footage from 00:03:53 to 00:06:23. Yet when I watch the 2nd mkv file in MPC the audio is still out of sync and the footage at the beginning of the file is ahead of where I indicated (00:03:53). What might the problem be?

b66pak
23rd August 2010, 20:26
mkvmerge -o my_video-part.mkv my_video.mkv --split 00:01:30 --split 00:03:45 --split-max-files 3

this mean you will end up with 3 files (--split-max-files 3): first 00:00:00 to 00:01:30, second 00:01:30 to 00:03:45 and third 00:03:45 to end of file!

the footage at the beginning of the file is ahead of where I indicated (00:03:53)

use 00:03:50 or lower!

sneaker_ger
23rd August 2010, 23:11
About the cuts not being exactly where specified: please note that mkvmerge cuts at the nearest keyframes - otherwise the video would be broken at the cuts. You cannot cut at non-keyframes without reencoding.
About the audio/video desync: you're saying that
a.) your mkv files are perfectly in sync, but
b.) after cutting with mkvmerge they are not?
That would be the first time for me to ever hear about such a problem. If you try b66pak's suggestion (using the global tab in the GUI should have the same result as using the commandline) on your original, still-in-sync files (not the demuxed or remuxed streams), I'm pretty sure the resulting files will be fine.

Why demuxing and remuxing destroys the sync between video and audio but not between audio and subtitles: you're probably dealing with variable framerate content (often anime) and did not take care of the timecodes thus destroying the sync.

Shinji-kun
9th September 2010, 19:24
Why demuxing and remuxing destroys the sync between video and audio but not between audio and subtitles: you're probably dealing with variable framerate content (often anime) and did not take care of the timecodes thus destroying the sync.

Cutting the original file seemed to work although the audio gets progressively out of sync. The greater in duration the clip is, the more out of sync it gets. The video is VFR.

sneaker_ger
9th September 2010, 19:48
If you have respected the following things, it should've worked:
1.) your original file is definitely in perfect sync over the whole time line
2.) you opened that original file in mmg
3.) you only used mmg for cutting using the "global" tab
4.) you did not set any "fps" in mmg (otherwise the timecodes from the original file will be overwritten) (<- maybe this?)
5.) you're using the same player for both the original and the cutted file

if you have respected all of the above and the file is still out of sync it could have one of the following reasons:
a.) your original file is broken
b.) you've found an error in mkvmerge
c.) your player is broken in some way or too slow (<- probably not this)

b66pak
9th September 2010, 20:03
also use the last mkvtoolnix (4.3.0)...
_