Author Topic: A/V sync problems with selfmade MKVs... Help?  (Read 1598 times)

Offline iindigo

  • Member
  • Posts: 2066
A/V sync problems with selfmade MKVs... Help?
« on: January 07, 2010, 09:19:08 PM »
So I recently acquired an Exiled-Destiny release of an anime I previously had. Both releases were DVD rips. The E-D release's video and audio were both quite clearly superior, but the old release's SSA softsubs and default Japanese audio do a much better job of keeping my eyes and ears intact and not clawed out than E-D's painful vobsubs and default English audio.

My solution? To (attempt) to create my own mix of the two, of course. For the most part, it's worked pretty well... I've discovered many of the ins and outs of mkvextract and mkvmerge and can create a pretty full-featured MKV with chapters, titles, etc.

A problem I ran into after merging E-D's audio and video with the other group's subs, however, is that the video is a few seconds behind the audio and progressively gets worse as the file plays on. I do research and find that this is due to the default duration of the video in my MKV defaulting to 25FPS instead of the 29.970FPS it's suppossed to run at. "No problem," I think, as I append --default-duration 1:29.970fps to the end of my mkvmerge command.

After the MKV file has compiled, I open it up to find that the problem still exists and that the --default-duration command has been ignored completely. The framerate is still that damn 25FPS.


Would any of the more video-savvy types around here know what I'm doing wrong? Here's the command I'm using, if it helps at all:
Code: [Select]
mkvmerge -o Episode\ 1.mkv ep1.avi ep1j.ac3 ep1e.ac3 ep1.ssa --default-duration 1:29.970fps --language 2:jpn --language 3:en --language 4:jpn

Thanks!
« Last Edit: January 07, 2010, 09:25:32 PM by iindigo »

Offline Excale

  • Member
  • Posts: 74
    • Fansub Group
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #1 on: January 08, 2010, 01:15:15 AM »
If you like, you can contact one of my team's encoders on my website (irc.raitian.info #exssubs) and pop in and post ur question.
One image in sig only.

Offline nstgc

  • Member
  • Posts: 7758
    • http://www.justfuckinggoogleit.com
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #2 on: January 10, 2010, 12:38:10 PM »
Could you pad either the video or audio, or crop one? That won't fix the rate difference, but it should fix the initial difference. I use the gui version whenever I have problems.

Also try this: --default-duration 0:30000/1001fps

Offline fohfoh

  • Member
  • Posts: 12031
  • Mod AznV~ We don't call it "Live Action"
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #3 on: January 11, 2010, 03:42:42 AM »
So you're having issues with the hard subs? Did you try toying around with soft subs?
This is your home now. So take advantage of everything here, except me.

Offline Slysoft

  • Member
  • Posts: 838
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #4 on: January 11, 2010, 06:49:22 AM »
get mkvtoolnix. It can't be any simpler. You just import the audio, video, and subtitle files and hit mux. Of course there are a ton of advanced settings but I don't mess with those. There's also a GUI or a command line version depending on which you prefer. This program is acknowledged by matroska themselves, so you can be sure that it's good.

http://www.bunkus.org/videotools/mkvtoolnix/index.html

It also works good for ripping tracks out of the mkv, if you for example liked one group's video but another group's subs.
« Last Edit: January 11, 2010, 06:51:36 AM by Slysoft »

Offline iindigo

  • Member
  • Posts: 2066
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #5 on: January 11, 2010, 01:55:48 PM »
Also try this: --default-duration 0:30000/1001fps

I fail to see how this will help when the --default-duration argument is being ignored totally, but if you insist I'll try it anyway.


So you're having issues with the hard subs? Did you try toying around with soft subs?

It's all explained in the original post, but here's a basic breakdown.

- I previously owned a DVD rip of this anime. Its SSA softsubs look great, but its video and audio kinda sucked.
- I recently obtained Exiled-Destiny's release of the same anime. Video and audio are great, but makes use of ass-ugly vobsubs (yellow, jagged, sitting-nearly-in-the-middle-of-the-screen, distracting DVD subs) and has the English dub set to default.

My intent was to combine the best from both releases, resulting in a dual-audio, SSA-subbed, japanese-default version of the anime with high video and audio quality.


get mkvtoolnix. It can't be any simpler. You just import the audio, video, and subtitle files and hit mux. Of course there are a ton of advanced settings but I don't mess with those. There's also a GUI or a command line version depending on which you prefer. This program is acknowledged by matroska themselves, so you can be sure that it's good.

http://www.bunkus.org/videotools/mkvtoolnix/index.html

It also works good for ripping tracks out of the mkv, if you for example liked one group's video but another group's subs.

Yes, the individual programs within the MKVToolnix package are what I'm currently using. They're commandline-only, since the UI is not functional on my ancient PowerPC Mac, but they seem to get the job done.

« Last Edit: January 11, 2010, 01:58:27 PM by iindigo »

Offline Blanchimont

  • Member
  • Posts: 1128
  • Dreamer through Time
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #6 on: January 11, 2010, 03:17:24 PM »
You're having the problem because most of E-D's encodes are vfr (variable framerate)...

So if you simply demux, and later remux the streams, of course they're going to be out of sync...

You have mkvtoolnix? Good, now get the add-on mkvextract to it unless you already have it, and extract the timecodes file from the original file.
When you mux back, just add the timecodes file (there's a selection for it on mkvmerge front, if you're using the gui), and voila, the remuxed file should be in sync :)

One problem you might also run into is if the audio is tagged with delay, but you should see what the delay is in the demuxed streams' names. If needed, just fill the right prompt in mkvmerge when remuxing with those values...

As for vfr, it's probably a lot easier to understand if you approach it from a completely different angle and forget all about normal framerates... Think of it as a set of frames with each having a set time to appear on the screen, and the player reads those times from the timecodes file where they are noted for each frame.*
 (*...if the timecodes file is v2 format, and that is what you get if you get it with mkvextract).

Most times vfr/variable framerate doesn't refer to encodes with very varying times for the frames globally (true vfr), but to encodes with both 24 fps & 30 fps sections, such E-D's encodes...

"..It's our dreams that guide us towards the future...not force"

Offline iindigo

  • Member
  • Posts: 2066
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #7 on: January 12, 2010, 10:03:57 AM »
You're having the problem because most of E-D's encodes are vfr (variable framerate)...

So if you simply demux, and later remux the streams, of course they're going to be out of sync...

You have mkvtoolnix? Good, now get the add-on mkvextract to it unless you already have it, and extract the timecodes file from the original file.
When you mux back, just add the timecodes file (there's a selection for it on mkvmerge front, if you're using the gui), and voila, the remuxed file should be in sync :)

One problem you might also run into is if the audio is tagged with delay, but you should see what the delay is in the demuxed streams' names. If needed, just fill the right prompt in mkvmerge when remuxing with those values...

As for vfr, it's probably a lot easier to understand if you approach it from a completely different angle and forget all about normal framerates... Think of it as a set of frames with each having a set time to appear on the screen, and the player reads those times from the timecodes file where they are noted for each frame.*
 (*...if the timecodes file is v2 format, and that is what you get if you get it with mkvextract).

Most times vfr/variable framerate doesn't refer to encodes with very varying times for the frames globally (true vfr), but to encodes with both 24 fps & 30 fps sections, such E-D's encodes...

Indeed. I have the entire MKVToolnix suite installed and have been using them all the whole time... they come as a package deal when installed through the port package manager, you see ;)

And yes, I tried toying with VFR before, extracting the timecodes from the E-D file and applying it to my freshly made MKV. Similarly to setting --default-duration, the codes were simply ignored and the video continued to play back at 25FPS. Perhaps I did something wrong, so I'll give it another shot...


Offline fizzmaister

  • Member
  • Posts: 40
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #8 on: January 14, 2010, 01:02:01 PM »
I don't know how much this will help you, but this is what I do in mmg (the gui for mkvMerge), maybe you can figure out the command line equivalent. Instead of extracting everything with mkv extract and then putting what I want back and adding the new things, I open the existing file in mmg, select the tracks that I want to keep, and add new tracks. Here are a few things that it spits out as the command line equivalent.

(click to show/hide)

I hope with these command line entries, you'll be able to get something to work without the gui. Best of luck.

Offline nstgc

  • Member
  • Posts: 7758
    • http://www.justfuckinggoogleit.com
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #9 on: January 14, 2010, 01:58:10 PM »
Also try this: --default-duration 0:30000/1001fps

I fail to see how this will help when the --default-duration argument is being ignored totally, but if you insist I'll try it anyway

What I was thinking was perhaps it didn't like the "1:29.970fps" you specified earlier. I found that some programs don't like it when you use decimals and preffer expressing it as a fraction. MEncoder is like that. I know that you aren't using MEncoder, but I figured I'd throw it out there.

Offline iindigo

  • Member
  • Posts: 2066
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #10 on: January 14, 2010, 08:54:47 PM »
Also try this: --default-duration 0:30000/1001fps

I fail to see how this will help when the --default-duration argument is being ignored totally, but if you insist I'll try it anyway

What I was thinking was perhaps it didn't like the "1:29.970fps" you specified earlier. I found that some programs don't like it when you use decimals and preffer expressing it as a fraction. MEncoder is like that. I know that you aren't using MEncoder, but I figured I'd throw it out there.

Ahh ok, thanks for explaining.

I found out what my problem was... I was inserting the command in the wrong area (I think) of the commandline string. Either way, I managed to get what I needed with a command quite similar to the ones fizzmaister posted (thanks, by the way - even if I didn't use those this time, they make great examples for future endeavors!).

Offline nstgc

  • Member
  • Posts: 7758
    • http://www.justfuckinggoogleit.com
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #11 on: January 17, 2010, 06:54:57 PM »
For future endeavors I would suggest MKVtoolnix-gui. It gives you the command line. I About a year and a half ago I wrote some scripts which ripped, encoded, and muxed DVDs. While MEncoder was pretty strait forward I found the muxing to be problematic. I used the GUI then copy and pasted the command line code into the script. Given that for anything longer then half an hour had a tendency to have the audio cut off (but the original, separated audio stream was fine) probably indicates that I shouldn't have completely relied on a GUI however. Still, its nice to start with something like that then fix it later. At least for me. You, iindigo, are using a Mac so you may not be a complete amateur like me though.

Just a suggestion.

Offline iindigo

  • Member
  • Posts: 2066
Re: A/V sync problems with selfmade MKVs... Help?
« Reply #12 on: January 17, 2010, 09:09:40 PM »
Ahh yeah... usually when the option is available, a GUI is nicer than the commandline (especially when the commands used are longer than most English sentences). As mentioned before, however, only really old builds of mmg (the MKVMerge UI) exist for the PowerPC (yes, I'm still stuck on a machine from 2005) and won't run properly. All newer builds have dropped support for PowerPCs entirely and will only run on Intel-based Macs, and thus I'm pretty much stuck with the CLI version whether I want to be or not :P

It's not that bad, though... I've become pretty accustomed to the command line over the past decade, so it's nothing new to me.