View Full Version : audio delay with mp4box
audyovydeo
4th March 2009, 12:52
Hello
I'm trying to add an audio delay to a file, but searching the forums I found differrent syntax :
mp4box -add video.h264 -add audio.aac -delay 2=200 -new syntax_old.mp4
mp4box -add video.h264 -add audio.aac:delay=200 -new syntax_new.mp4
Both of these cmdlines execute correctly, but since no message is returned, how can I tell if the delay has been set ? Neither mp4box nor media info give any clue on delay.
thanks
a/v
Kurtnoise
4th March 2009, 13:11
Both of these cmdlines execute correctly, but since no message is returned, how can I tell if the delay has been set ? Neither mp4box nor media info give any clue on delay.
did you try :
MP4Box -info syntax_xxx.mp4
and check duration ?
audyovydeo
4th March 2009, 13:15
did you try :
MP4Box -info syntax_xxx.mp4
and check duration ?
hello kurtnoise, thanks for quick reply.
Yes, nothing significant.
I had an mp4 file which I demuxed using mp4box (0.4.5-DEV (build 19 - Apr 13 2008), then I muxed as previously posted.
-info gives me exactly the same durations as my source file.
that said, I just tried with a delay of 600 to make it obvious, and it worked. but -info still shows the same duration
cheers
a/v
djenyc
4th April 2011, 22:20
-info gives me exactly the same durations as my source file.
that said, I just tried with a delay of 600 to make it obvious, and it worked. but -info still shows the same duration
cheers
a/v
I'm having exact same issue, so I thought I'd reply to this thread instead of starting a new thread.
So here's the problem - When adding delay to audio using Mp4Box - the delay command seem to work as intended (tested by playing back in KMplayer), but I can't find a way to check on how much delay is in the file after adding the delay. MP4Box -info command shows exact same output before adding the delay and after adding the delay. There is also no indication about the delay in MediaInfo that I can find and the track lengths remain the same. I can post both logs if there is interest.
So after I add delay to MP4 file, how can I check how much delay is in it? I'll need to know this delay in case I want to edit/remux the file later on.
djenyc
6th April 2011, 17:34
Did some more experimenting - FFAudioSource in avisynth can adjust for the delay
FFAudioSource(adjustdelay = -1)
Controls how audio delay is handled, i.e. what happens if the first audio sample in the file doesn't have a timestamp of zero. The following arguments are valid:
* -3: No adjustment is made; the first decodable audio sample becomes the first sample in the output.
* -2: Samples are created (with silence) or discarded so that sample 0 in the decoded audio starts at time zero.
* -1: Samples are created (with silence) or discarded so that sample 0 in the decoded audio starts at the same time as frame 0 of the first video track. This is the default, and probably what most people want.
So can tell how much delay there is by comparing length of FFAudioSource(adjustdelay = -1) and FFAudioSource(adjustdelay = -3).
---
On a separate note, I needed to sync audio using negative delay, and mp4box does not support that, so I tried delaying the video, and something is screwed up - the delay I get on playback was more than I specified by about 60 milliseconds. Not sure what's wrong, may be MP4box video delay is broken or there are some other issues. So to sum it up - adding audio delay works as intended, but can only use positive delay / delaying video results in a wrong offset being applied.
b66pak
6th April 2011, 20:26
considering that a lot of devices (phones, PS3, PSP, maybe iDevices) can't deal with audio/video delay i suggest to correct the audio delay before muxing...a very good tool is eac3to...also a +/- 50ms delay is imperceptible...
_
djenyc
7th April 2011, 19:57
considering that a lot of devices (phones, PS3, PSP, maybe iDevices) can't deal with audio/video delay i suggest to correct the audio delay before muxing...a very good tool is eac3to...also a +/- 50ms delay is imperceptible...
_
Good point. Support for delay in mp4 container is definitely not universal.
On another note, just found something else odd with the mp4 container. NeroAacEnc was adding 119ms delay, so took 119ms out of the wav file before feeding to Nero - now it should have no delay between audio/video. I muxed it to MP4 with MP4Box (stripping chapters info that Nero puts in to account for the delay) - it now plays in-sync with some players (VLC, Mplayer, KMplayer w Haali splitter), but out of sync with QuickTime and KMplayer w. internal splitter. No idea what's going on, may be mp4 playback is just inconsistent.
I'm processing a bunch of videos that I shot with my Canon HF10 AVCHD camcorder and need to store them in something reliable, so I took the same tracks and put in to MKV container and now everything is playing in-sync consistently across all players (except QuickTime that does not support mkv.
Using MKV opens up another possibility of using OGG instead of AAC for the audio track. With OGG there is no delay to deal with, because, unlike AAC, OGG has built-in supports for gapless encoding (source: http://en.wikipedia.org/wiki/Gapless_playback).
So in my experience so far:
x264/AAC in MP4 - no good.
x264/AAC in MKV - in synch as long as provisions are made to adjust for the delay
x264/OGG in MKV - PERFECT!
---
Found similar problem discussed here:
http://forum.doom9.org/showthread.php?t=156163
Same conclusion - NeroAacEnc adds delay, MP4 has inherent sync issues (at least when muxed with MP4Box), MKV gets the timing right
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.