VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. Member
    Join Date
    Mar 2003
    Location
    United Kingdom
    Search Comp PM
    Just tried my normal encoding process on a new .mp4 file. The process is: demuxing the source, encoding the video to MPEG2 with HCENC, audio to AC3 with ffmpeg, then remux with mplex to get a file suitable for DVD authoring. But it didn't work; the audio is about 4 seconds delayed compared to the video. Looking at the source file in more detail with mp4box, it appears that the audio stream is 4 seconds longer than the video. I assume there's a flag somewhere in the multiplexing data of the file that says to skip the first 4 seconds of the audio stream (which are completely silent), but can anyone point me in the direction of something that can read it and confirm that this is what's really going on...?
    Quote Quote  
  2. are the video & audio the same lengths and just shifted 4 seconds apart? this would be constant 4 seconds throughout the whole video

    or are they different lengths? this would be progressively worsening A/V sync over time

    or is it completely something else?

    What are the specs of the mp4 file? use mediainfo (view=>text) copy & paste the info back here

    Are you making a PAL spec DVD?
    Quote Quote  
  3. Member
    Join Date
    Mar 2003
    Location
    United Kingdom
    Search Comp PM
    Format : MPEG-4
    Format profile : Base Media
    Codec ID : isom
    File size : 2.50 GiB
    Duration : 2h 10mn
    Overall bit rate : 2 743 Kbps
    Encoded date : UTC 2010-09-17 01:09:14
    Tagged date : UTC 2010-09-17 01:09:14

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L4.1
    Format settings, CABAC : Yes
    Format settings, ReFrames : 4 frames
    Format settings, GOP : M=4, N=48
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 2h 10mn
    Bit rate mode : Variable
    Bit rate : 2 366 Kbps
    Maximum bit rate : 15.1 Mbps
    Width : 1 280 pixels
    Height : 544 pixels
    Display aspect ratio : 2.35:1
    Frame rate mode : Constant
    Frame rate : 23.976 fps
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.142
    Stream size : 2.15 GiB (86%)
    Writing library : x264 core 104 r1677 19df41a
    Encoding settings : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3
    :0x113 / me=hex / subme=4 / psy=1 / psy_rd=0.00:0.00 / mixed_ref=0 / me_range=16
    / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 /
    chroma_qp_offset=0 / threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlac
    ed=0 / constrained_intra=0 / bframes=3 / b_pyramid=0 / b_adapt=1 / b_bias=0 / di
    rect=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=23 / scene
    cut=40 / intra_refresh=0 / rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=2366
    / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qb
    lur=0.5 / ip_ratio=1.40 / aq=1:1.00
    Encoded date : UTC 2010-09-16 14:12:54
    Tagged date : UTC 2010-09-17 01:12:55

    Audio
    ID : 2
    Format : AAC
    Format/Info : Advanced Audio Codec
    Format profile : LC
    Codec ID : 40
    Duration : 2h 10mn
    Bit rate mode : Variable
    Bit rate : 375 Kbps
    Maximum bit rate : 496 Kbps
    Channel(s) : 6 channels
    Channel positions : Front: L C R, Side: L R, LFE
    Sampling rate : 48.0 KHz
    Compression mode : Lossy
    Stream size : 350 MiB (14%)
    Language : English
    Encoded date : UTC 2010-09-17 01:12:18
    Tagged date : UTC 2010-09-17 01:12:55

    The offset is a constant 4 seconds. It's as if on playback the first 4 seconds of the source file's audio should be ignored. Yes, I'm making a PAL dvd, although the same problem occurs if I go for NTSC-film.

    Edit: The duration accuracy mediainfo produces in its default format isn't enough to see the problem. Here's the full accuracy version:

    Video Duration : 02:10:25.284
    Audio Duration : 02:10:29.930
    Quote Quote  
  4. If it's a constant delay offset , you can set your multiplexer to give -4000ms delay or +4000ms delay depending on which way you want to shift the audio. Depending on what you used to demux, it should give you the exact value of the delay (e.g. if you used dgindex to demux it)

    If it's the audio that has silence in the beginning, and the audio is actually 4s longer, you can use delaycut to trim it off

    AVStoDVD should be able automate everything for you (you have the choice to use HCEnc as the encoder)

    EDIT:
    It appears your video & audio duration don't match
    How did you get the duration? Is that from the demultiplexed files before processing (encoding) or after?
    Last edited by poisondeathray; 10th Feb 2011 at 18:55.
    Quote Quote  
  5. Member
    Join Date
    Mar 2003
    Location
    United Kingdom
    Search Comp PM
    Those durations are from the source file.
    Quote Quote  
  6. That can be normal if the mp4 file was muxed with the delay (I'm assuming the mp4 is in sync)


    Here the container holds the delay relationship between audio & video (audio longer than video, 1st part of audio is silent)
    _VVVV
    AAAAA

    When you demux it, the delay relationship between audio & video is lost (elementary video & audio)
    VVVV
    AAAAA

    So if the audio is only silence at the beginning, you can use delaycut to snip it

    or another approach is to mux the encoded streams with the delay value

    or you can encode it together using avisynth scripts (this basically takes care of the delay, because it's read from the container), so the transcoded AC3 no longer has the gap in the beginning

    aud=ffaudiosource("myvideo.mp4")
    vid=ffvideosource("myvideo.mp4")
    audiodub(vid,aud)
    lanczosresize(720,480) #this is for ntsc

    If you wanted PAL, you would need to speedup the audio & video
    aud=ffaudiosource("myvideo.mp4")
    vid=ffvideosource("myvideo.mp4")
    audiodub(vid,aud)
    lanczosresize(720,576) #this is for pal
    assumefps(25, true) #this does pal speedup for both audio & video


    or you can try AVStoDVD which will pretty much do everything automatically for you
    Last edited by poisondeathray; 10th Feb 2011 at 19:51.
    Quote Quote  
  7. Member
    Join Date
    Mar 2003
    Location
    United Kingdom
    Search Comp PM
    That can be normal if the mp4 file was muxed with the delay (I'm assuming the mp4 is in sync)


    Here the container holds the delay relationship between audio & video (audio longer than video, 1st part of audio is silent)
    _VVVV
    AAAAA

    When you demux it, the delay relationship between audio & video is lost (elementary video & audio)
    VVVV
    AAAAA
    That's what I guessed, but what I'd really like at this point is a tool that will examine the container and tell me precisely how much delay is in use, so that I can reconstruct the sync exactly. Having tried it with the 4646ms length difference between the two streams, this doesn't seem to be the precisely correct figure...
    Quote Quote  
  8. Try demuxing the .mp4 with dgavcindex, and the delay value should be written into the .aac audio filename

    It will say something like this

    BLAH T80 2_0ch 192Kbps DELAY 572ms.aac
    Quote Quote  
  9. Is the source out of sync and/or is it in sync at the start and goes out of sync slowly getting worse near the end?
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!