Video lags audio by 1.5 seconds

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
basic_user
Posts: 7
Joined: Thu Mar 29, 2018 3:26 am

Video lags audio by 1.5 seconds

Post by basic_user »

Description of problem or question:
5 episodes on this particular DVD. All ripped in one sitting with MakeMKV. 4 of them converted to MP4 without issue. 1 of them has a video lag of about 1.5 seconds behind the audio.
I just upgraded HandBrake in hopes of solving this, but no dice. Have used MakeMKV and HandBrake for a few years now and have run into this a couple times. Previously I just left it in mkv format but it's finally bugging me enough to ask. Yes, compressing/converting to mkv format works fine.

Here's a head scratcher on this though; when I preview from the beginning it's out of sync, when I preview from anywhere else it's fine.



Steps to reproduce the problem (If Applicable):
Every time. No variance in the sync issue regardless of framerate or Align A/V Started checked or not.



HandBrake version (e.g., 1.0.0):
1.3.1



Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows 7 Home Premium



HandBrake Activity Log ***required*** (see How-to get an activity log)

Code: Select all

HandBrake 1.3.1 (2020010400)
OS: Microsoft Windows NT 6.1.7601 Service Pack 1
CPU: Intel(R) Core(TM) i3 CPU         550  @ 3.20GHz
Ram: 8119 MB, 
GPU Information:
  NVIDIA GeForce GT 240 - 21.21.13.4201
Screen: 1920x1080
Temp Dir: C:\Users\me\AppData\Local\Temp\
Install Dir: C:\Program Files\Handbrake
Data Dir: C:\Users\me\AppData\Roaming\HandBrake

-------------------------------------------


# Starting Encode ...

[22:11:46] hb_init: starting libhb thread
[22:11:46] Starting work at: Tue Feb 11 22:11:46 2020
[22:11:46] 1 job(s) to process
[22:11:46] json job:
{
  "Audio": {
    "AudioList": [
      {
        "Bitrate": 160,
        "DRC": 0.0,
        "Encoder": "av_aac",
        "Gain": 0.0,
        "Mixdown": 4,
        "NormalizeMixLevel": false,
        "Samplerate": 0,
        "Name": "Surround 5.1",
        "Track": 0,
        "DitherMethod": 0
      }
    ],
    "CopyMask": [
      "copy:aac",
      "copy:ac3",
      "copy:dtshd",
      "copy:dts",
      "copy:eac3",
      "copy:flac",
      "copy:mp3",
      "copy:truehd"
    ],
    "FallbackEncoder": "ac3"
  },
  "Destination": {
    "ChapterList": [
      {
        "Name": "Chapter 1"
      },
      {
        "Name": "Chapter 2"
      },
      {
        "Name": "Chapter 3"
      },
      {
        "Name": "Chapter 4"
      },
      {
        "Name": "Chapter 5"
      },
      {
        "Name": "Chapter 6"
      },
      {
        "Name": "Chapter 7"
      }
    ],
    "ChapterMarkers": true,
    "AlignAVStart": true,
    "File": "C:\\Users\\me\\Videos\\Supernatural S13 E03 - Patience-1_preview.m4v",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": false
    },
    "Mux": "mp4"
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 4,
        "Settings": {
          "mode": "7"
        }
      },
      {
        "ID": 3,
        "Settings": {
          "block-height": "16",
          "block-thresh": "40",
          "block-width": "16",
          "filter-mode": "2",
          "mode": "3",
          "motion-thresh": "1",
          "spatial-metric": "2",
          "spatial-thresh": "1"
        }
      },
      {
        "ID": 12,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "480",
          "width": "720"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "2",
          "rate": "27000000/900000"
        }
      }
    ]
  },
  "PAR": {
    "Num": 32,
    "Den": 27
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "preview",
      "Start": 2,
      "End": 900000,
      "SeekPoints": 10
    },
    "Title": 1,
    "Path": "C:\\Users\\me\\Videos\\FullDisc\\SUPERNATURAL_S13_E03 - Patience.mkv"
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": false,
      "Forced": false
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "x264",
    "Level": "4.0",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "",
    "Preset": "fast",
    "Profile": "main",
    "Quality": 22.0,
    "QSV": {
      "Decode": false,
      "AsyncDepth": 0
    }
  }
}
[22:11:46] CPU: Intel(R) Core(TM) i3 CPU         550  @ 3.20GHz
[22:11:46]  - logical processor count: 4
[22:11:46] Intel Quick Sync Video support: no
[22:11:46] hb_scan: path=C:\Users\me\Videos\FullDisc\SUPERNATURAL_S13_E03 - Patience.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:323: failed opening UDF image C:\Users\me\Videos\FullDisc\SUPERNATURAL_S13_E03 - Patience.mkv
src/libbluray/disc/disc.c:424: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:424: error opening file BDMV\BACKUP\index.bdmv
src/libbluray/bluray.c:2585: nav_get_title_list(C:\Users\me\Videos\FullDisc\SUPERNATURAL_S13_E03 - Patience.mkv\) failed
[22:11:46] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[22:11:46] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'C:\Users\me\Videos\FullDisc\SUPERNATURAL_S13_E03 - Patience.mkv':
  Metadata:
    encoder         : libmakemkv v1.14.7 (1.3.5/1.4.7) win(x64-release)
    creation_time   : 2020-02-07T22:10:11.000000Z
  Duration: 00:35:45.28, start: 0.000000, bitrate: 4393 kb/s
    Chapter #0:0: start 0.000000, end 49.716333
    Metadata:
      title           : Chapter 01
    Chapter #0:1: start 49.716333, end 167.667500
    Metadata:
      title           : Chapter 02
    Chapter #0:2: start 167.667500, end 858.524333
    Metadata:
      title           : Chapter 03
    Chapter #0:3: start 858.524333, end 1183.682500
    Metadata:
      title           : Chapter 04
    Chapter #0:4: start 1183.682500, end 1806.805000
    Metadata:
      title           : Chapter 05
    Chapter #0:5: start 1806.805000, end 2116.114000
    Metadata:
      title           : Chapter 06
    Chapter #0:6: start 2116.114000, end 2145.276467
    Metadata:
      title           : Chapter 07
    Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 32:27 DAR 16:9], SAR 186:157 DAR 279:157, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
    Metadata:
      BPS-eng         : 3797104
      DURATION-eng    : 00:35:45.276466666
      NUMBER_OF_FRAMES-eng: 51436
      NUMBER_OF_BYTES-eng: 1018229760
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
    Metadata:
      title           : Surround 5.1
      BPS-eng         : 384000
      DURATION-eng    : 00:35:43.264000000
      NUMBER_OF_FRAMES-eng: 66977
      NUMBER_OF_BYTES-eng: 102876672
      SOURCE_ID-eng   : 0180BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:2(por): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 00:35:45.248000000
      NUMBER_OF_FRAMES-eng: 67039
      NUMBER_OF_BYTES-eng: 51485952
      SOURCE_ID-eng   : 0181BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:3(eng): Subtitle: dvd_subtitle, 720x480 (default)
    Metadata:
      BPS-eng         : 3638
      DURATION-eng    : 00:35:39.492900000
      NUMBER_OF_FRAMES-eng: 524
      NUMBER_OF_BYTES-eng: 973080
      SOURCE_ID-eng   : 0120BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:4(chi): Subtitle: dvd_subtitle, 720x480
    Metadata:
      BPS-eng         : 2650
      DURATION-eng    : 00:35:36.489900000
      NUMBER_OF_FRAMES-eng: 443
      NUMBER_OF_BYTES-eng: 707872
      SOURCE_ID-eng   : 0122BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:5(fre): Subtitle: dvd_subtitle, 720x480
    Metadata:
      BPS-eng         : 2846
      DURATION-eng    : 00:35:34.921666666
      NUMBER_OF_FRAMES-eng: 458
      NUMBER_OF_BYTES-eng: 759552
      SOURCE_ID-eng   : 0124BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:6(por): Subtitle: dvd_subtitle, 720x480
    Metadata:
      BPS-eng         : 2864
      DURATION-eng    : 00:35:39.426166666
      NUMBER_OF_FRAMES-eng: 489
      NUMBER_OF_BYTES-eng: 766160
      SOURCE_ID-eng   : 0126BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:7(spa): Subtitle: dvd_subtitle, 720x480
    Metadata:
      BPS-eng         : 2910
      DURATION-eng    : 00:35:39.426166666
      NUMBER_OF_FRAMES-eng: 488
      NUMBER_OF_BYTES-eng: 778368
      SOURCE_ID-eng   : 0128BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:8(por): Subtitle: dvd_subtitle, 720x480
    Metadata:
      BPS-eng         : 34
      DURATION-eng    : 00:35:36.556633333
      NUMBER_OF_FRAMES-eng: 7
      NUMBER_OF_BYTES-eng: 9132
      SOURCE_ID-eng   : 012ABD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-07 22:10:11
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
[22:11:46] scan: decoding previews for title 1
[22:11:46] scan: audio 0x2: ac3, rate=48000Hz, bitrate=192000 Portugues (AC3) (2.0 ch) (Dolby Surround) (192 kbps)
[22:11:46] scan: audio 0x1: ac3, rate=48000Hz, bitrate=384000 English (AC3) (5.1 ch) (384 kbps)
[22:11:46] scan: 10 previews, 720x480, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 32:27
[22:11:46] libhb: scan thread found 1 valid title(s)
[22:11:46] Starting Task: Encoding Pass
[22:11:46] Skipping crop/scale filter
[22:11:46] job configuration:
[22:11:46]  * source
[22:11:46]    + C:\Users\me\Videos\FullDisc\SUPERNATURAL_S13_E03 - Patience.mkv
[22:11:46]    + title 1, start 00:00:0.00 stop 00:00:10.00
[22:11:46]    + container: matroska,webm
[22:11:46]    + data rate: 4393 kbps
[22:11:46]  * destination
[22:11:46]    + C:\Users\me\Videos\Supernatural S13 E03 - Patience-1_preview.m4v
[22:11:46]    + container: MPEG-4 (libavformat)
[22:11:46]      + align initial A/V stream timestamps
[22:11:46]      + chapter markers
[22:11:46]  * video track
[22:11:46]    + decoder: mpeg2video
[22:11:46]    + filters
[22:11:46]      + Comb Detect (mode=3:spatial-metric=2:motion-thresh=1:spatial-thresh=1:filter-mode=2:block-thresh=40:block-width=16:block-height=16)
[22:11:46]      + Decomb (mode=39)
[22:11:46]      + Framerate Shaper (mode=2:rate=27000000/900000)
[22:11:46]        + frame rate: 23.976 fps -> peak rate limited to 30.000 fps
[22:11:46]    + Output geometry
[22:11:46]      + storage dimensions: 720 x 480
[22:11:46]      + pixel aspect ratio: 32 : 27
[22:11:46]      + display dimensions: 853 x 480
[22:11:46]    + encoder: H.264 (libx264)
[22:11:46]      + preset:  fast
[22:11:46]      + profile: main
[22:11:46]      + level:   4.0
[22:11:46]      + quality: 22.00 (RF)
[22:11:46]      + color profile: 6-1-6
[22:11:46]  * audio track 1
[22:11:46]    + name: Surround 5.1
[22:11:46]    + decoder: English (AC3) (5.1 ch) (384 kbps) (track 1, id 0x1)
[22:11:46]      + bitrate: 384 kbps, samplerate: 48000 Hz
[22:11:46]    + mixdown: Stereo
[22:11:46]    + dither: none
[22:11:46]    + encoder: AAC (libavcodec)
[22:11:46]      + bitrate: 160 kbps, samplerate: 48000 Hz
[22:11:46] sync: expecting 263 video frames
[22:11:46] encx264: min-keyint: 24, keyint: 240
[22:11:46] encx264: encoding at constant RF 22.000000
[22:11:46] encx264: unparsed options: level=4.0:ref=2:8x8dct=0:weightp=1:subme=6:vbv-bufsize=25000:vbv-maxrate=20000:rc-lookahead=30
x264 [info]: using SAR=32/27
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
x264 [info]: profile Main, level 4.0, 4:2:0, 8-bit
[22:11:46] sync: first pts video is 0
[22:11:46] sync: "Chapter 3" (3) at frame 1 time 0
[22:11:46] sync: first pts audio 0x1 is 0
[22:11:49] sync: reached audio 0x1 pts 900720, exiting early
[22:11:49] sync: reached video pts 900900, exiting early
[22:11:49] work: average encoding speed for job is 0.000000 fps
[22:11:49] comb detect: heavy 0 | light 0 | uncombed 240 | total 240
[22:11:49] decomb: deinterlaced 0 | blended 0 | unfiltered 240 | total 240
[22:11:49] vfr: 240 frames output, 0 dropped and 0 duped for CFR/PFR
[22:11:49] vfr: lost time: 0 (0 frames)
[22:11:49] vfr: gained time: 0 (0 frames) (0 not accounted for)
[22:11:49] ac3-decoder done: 821 frames, 0 decoder errors
[22:11:49] mpeg2video-decoder done: 617 frames, 0 decoder errors
[22:11:49] sync: got 240 frames, 263 expected
[22:11:49] sync: framerate min 23.976 fps, max 23.976 fps, avg 23.976 fps
x264 [info]: frame I:5     Avg QP:17.77  size: 14746
x264 [info]: frame P:71    Avg QP:20.33  size:  2763
x264 [info]: frame B:164   Avg QP:21.89  size:   760
x264 [info]: consecutive B-frames:  2.9% 10.0% 23.8% 63.3%
x264 [info]: mb I  I16..4: 46.9%  0.0% 53.1%
x264 [info]: mb P  I16..4:  1.0%  0.0%  0.8%  P16..4: 39.4%  8.5%  6.7%  0.0%  0.0%    skip:43.6%
x264 [info]: mb B  I16..4:  1.1%  0.0%  0.1%  B16..8: 14.0%  1.3%  0.0%  direct:12.5%  skip:71.0%  L0:43.3% L1:52.7% BI: 4.0%
x264 [info]: coded y,uvDC,uvAC intra: 40.2% 61.9% 21.9% inter: 3.1% 20.5% 0.0%
x264 [info]: i16 v,h,dc,p: 46% 15% 12% 28%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 12% 17%  5%  7%  8%  4%  6%  3%
x264 [info]: i8c dc,h,v,p: 57% 17% 22%  5%
x264 [info]: Weighted P-Frames: Y:2.8% UV:0.0%
x264 [info]: ref P L0: 60.2% 39.8%
x264 [info]: ref B L0: 72.2% 27.8%
x264 [info]: ref B L1: 94.8%  5.2%
x264 [info]: kb/s:315.23
[22:11:49] mux: track 0, 240 frames, 394210 bytes, 313.75 kbps, fifo 256
[22:11:49] mux: track 1, 470 frames, 203370 bytes, 161.86 kbps, fifo 512
[22:11:49] Finished work at: Tue Feb 11 22:11:49 2020
[22:11:49] libhb: work result = 0

# Encode Completed ...



akyhne
Posts: 26
Joined: Sat Feb 08, 2020 1:02 am

Re: Video lags audio by 1.5 seconds

Post by akyhne »

Question: Why would you want to re-encode the file twice?
If you just want to change from .mkv to .mp4, you can just remux the file. Demux (extract) audio, video and subtitle streams from the MKV and remux (repack) into MP4.

MKV files supports audio delay, MP4 doesn't. So there could be set an audio delay in the MKV file, that doesn't tranfer to the MP4. Only a test will tell.
Demux from MKV with MKVToolnix installed and witth the software MKVCleaver. Remux with My MP4Box GUI.

musicvid
Veteran User
Posts: 3442
Joined: Sat Jun 27, 2009 1:19 am

Re: Video lags audio by 1.5 seconds

Post by musicvid »

MKV files supports audio delay, MP4 doesn't.
MKV is a wrapper, whose contained formats may or may not support audio delay.
MP4 is a format supports and universally employs audio delay as a replacement for interleave.
Delays of 42-44ms are very typical of MP4 AVC.

mduell
Veteran User
Posts: 6885
Joined: Sat Apr 21, 2007 8:54 pm

Re: Video lags audio by 1.5 seconds

Post by mduell »

RoyaleNite wrote:
Wed Feb 12, 2020 4:49 pm
How do I submit my own question, this is the most complecated website ever to just post a fricking question
Start a new thread with the requisite information. Highly recommended to read and follow the bold underlined red text at the top of the page.

akyhne
Posts: 26
Joined: Sat Feb 08, 2020 1:02 am

Re: Video lags audio by 1.5 seconds

Post by akyhne »

musicvid wrote:
Wed Feb 12, 2020 6:14 pm
MKV is a wrapper, whose contained formats may or may not support audio delay.
I don't know what audio formats that should be. You can put a delay on any audio, AFAIC tell with MKVToolNix. The help in MKVToolNix GUI states the same.
Just made a test with TrueHD, DTS-HD-MA, AC-3, PCM, FLAC, MP2, AAC and MP3.
All worked in VLC, one failed on my Sony UBP-X800 blu-ray player, by only playing silence (uncompressed 5.1 PCM).

basic_user
Posts: 7
Joined: Thu Mar 29, 2018 3:26 am

Re: Video lags audio by 1.5 seconds

Post by basic_user »

The reason for the conversion is primarily ease of playback. Whether it be on a Roku, AppleTV, copied to a phone, etc. MP4 is pretty universal afaik.

So now that the 'why' is out of the way, any ideas on the 'how'?

It's only the one episode, all the rest are fine. I've gone through every framerate in the dropdown with the exact same result. I'm not sure what else to try or check.

akyhne
Posts: 26
Joined: Sat Feb 08, 2020 1:02 am

Re: Video lags audio by 1.5 seconds

Post by akyhne »

You'd need to find out whether the delay is a software or file based.

What I mean by that is that the audio file itself could have a 1,5 second empty signal at the beginning, thus the whole track is 1,5 second ahead, or it could be the MKV that is set to start the audio stream 1,5 seconds sooner.

Play the video file and pause at the exact moment someone starts speaking or whatever.
Extract the audio and import into a wave (audio) editor and do the same.

If the start point is the same, it's the MKV doing some delay. Hard to help any further without knowing.

basic_user
Posts: 7
Joined: Thu Mar 29, 2018 3:26 am

Re: Video lags audio by 1.5 seconds

Post by basic_user »

As my screen name should intimate, I know very little about this process. I don't know how to extract audio and I have no idea what to do with a wave editor.
When I play the ripped mkv file with VLC it plays just perfectly. When I 'convert' the ripped mkv file into a smaller mkv file it also works perfectly. It's the conversion to mp4 that gets all bollixed.

So if further help would require all that video voodoo I think I'm just stuck with one episode being in a different format from the rest. (more episodes after those are also working just fine).

Thank you for the attempts.

basic_user
Posts: 7
Joined: Thu Mar 29, 2018 3:26 am

Re: Video lags audio by 1.5 seconds

Post by basic_user »

Quick update and close to this. After I laid out the above I wondered what would happen if I converted the converted file. So the process was:

DVD --> mkv --> compressed mkv --> mp4

This resulted in a perfectly fine mp4. No idea why but I'll be keeping this in mind for the rare cases where this comes up.

Post Reply