Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Newbies

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st April 2019, 02:01   #1  |  Link
Vilx-
Registered User
 
Join Date: May 2011
Posts: 28
Audio subtly lags behind video - how to fix?

I have an MKV file that has an issue with the audio - it subtly lags behind the video. They start in sync, and then over the course of the whole clip they drift out of sync.

My first idea was that the video framerate is specified wrong by 1, but a quick calculation shows that the effect would be MUCH more pronounced then. I'm at a loss how this could have happened, and better yet - how do I correct it now, since I don't have access to the original source from which it was encoded anymore? Here's the output from MediaInfo:

Code:
General
Unique ID                                : [Redacted]
Complete name                            : [Redacted]
Format                                   : Matroska
Format version                           : Version 4
File size                                : 823 MiB
Duration                                 : 22 min 17 s
Overall bit rate                         : 5 164 kb/s
Encoded date                             : UTC 2017-10-16 18:54:58
Writing application                      : mkvmerge v17.0.0 ('Be Ur Friend') 64-bit
Writing library                          : libebml v1.3.5 + libmatroska v1.4.8

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 2 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 2 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 22 min 14 s
Bit rate                                 : 4 920 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 24.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.099
Stream size                              : 772 MiB (94%)
Writing library                          : x264 core 115 r1995M 5a37283
Encoding settings                        : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 
                                           / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 
                                           / chroma_qp_offset=0 / threads=4 / sliced_threads=0 / nr=250 / decimate=1 / interlaced=0 / bluray_compat=0 
                                           / constrained_intra=0 / bframes=0 / weightp=1 / keyint=250 / keyint_min=24 / scenecut=40 / intra_refresh=0 
                                           / rc_lookahead=10 / rc=2pass / mbtree=1 / bitrate=4920 / ratetol=1.0 / qcomp=0.60 / qpmin=5 / qpmax=69 
                                           / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00
Language                                 : English
Default                                  : Yes
Forced                                   : No

Audio #1
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : A_AC3
Duration                                 : 22 min 17 s
Bit rate mode                            : Constant
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 30.6 MiB (4%)
Language                                 : Russian
Service kind                             : Complete Main
Default                                  : Yes
Forced                                   : No

Audio #2
ID                                       : 3
Format                                   : AAC LC SBR
Format/Info                              : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name                          : HE-AAC
Format settings                          : Explicit
Codec ID                                 : A_AAC-2
Duration                                 : 22 min 16 s
Bit rate                                 : 127 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 23.438 FPS (2048 SPF)
Compression mode                         : Lossy
Stream size                              : 20.2 MiB (2%)
Language                                 : English
Default                                  : No
Forced                                   : No
As you can see, the video is 22:14 long, while the sound is 22:17 long. Thus over the course of 22 minutes the sound drifts 3 seconds out of sync. To correct that in the framerate, the video would need to be played at about 24.054fps, but that's not any standard framerate I know of.

Last edited by Vilx-; 21st April 2019 at 02:03.
Vilx- is offline   Reply With Quote
Old 22nd April 2019, 00:56   #2  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
You should do a little experimenting with MKVMergeGUI...

Load your MKV, highlight the video stream in the lower left window and have a look at the "Time codes and default duration" section in the right pane. You can either stretch the video by a certain factor, or you can specify the default duration for the video. Optionally you can also adapt the duration in the bitstream to the value in the container. Play around with the options...
manolito is offline   Reply With Quote
Old 22nd April 2019, 15:30   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Vilx- View Post
I have an MKV file that has an issue with the audio - it subtly lags behind the video. They start in sync, and then over the course of the whole clip they drift out of sync.
Please explain how exactly you created or obtained this file.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 22nd April 2019, 18:15   #4  |  Link
mkver
Registered User
 
Join Date: May 2016
Posts: 197
Quote:
Originally Posted by Vilx- View Post
As you can see, the video is 22:14 long, while the sound is 22:17 long. Thus over the course of 22 minutes the sound drifts 3 seconds out of sync. To correct that in the framerate, the video would need to be played at about 24.054fps, but that's not any standard framerate I know of.
That's not true. In order for the video to be stretched to 22:17, the video framerate needs to be decreased, not increased. So the first thing I'd do is testing whether the video should run at 24/1.001 fps.

And MediaInfo's output (which is only exact down to a second) is not good enough for what you are trying to achieve. MediaInfo can be made to be more precise or you can e.g. use mkvinfo (part of MKVToolNix).

Last edited by mkver; 22nd April 2019 at 18:17.
mkver is offline   Reply With Quote
Old 22nd April 2019, 20:52   #5  |  Link
gonca
Registered User
 
Join Date: Jul 2012
Posts: 1,213
Video 22min 14sec
Audio 1 22min 17sec
Audio 2 22min 16sec

Adjust audio in mkvtoolnix gui (right side stretch by)

Audio 1 0.9978
Audio 2 0.9985
Or clip the audio accordingly

And don't forget to answer LoRd_MuldeR's question

Last edited by gonca; 22nd April 2019 at 20:58.
gonca is offline   Reply With Quote
Old 25th April 2019, 22:24   #6  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
I'd first try slowing the video to 23.976fps, as the MediaInfo readout says it's 24fps. That was mkver's earlier suggestion.
manono is offline   Reply With Quote
Old 25th April 2019, 22:58   #7  |  Link
gonca
Registered User
 
Join Date: Jul 2012
Posts: 1,213
Quote:
Originally Posted by manono View Post
I'd first try slowing the video to 23.976fps, as the MediaInfo readout says it's 24fps. That was mkver's earlier suggestion.
But there are two audio tracks with two different durations.
One speed/time adjustment can't correct both tracks.

Of course if the sync drift is different for the two tracks then 23.976 might work.
Either way, won't hurt to try either method

Last edited by gonca; 25th April 2019 at 23:01.
gonca is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.