Hi all, I'm trying to add a 170ms delay to an AC3 audio track (stereo, 48kHz, 224kbps) using ffmpeg, but neither of the following seems to work:
Method 1: the concat filter (seems preferable, since it does not re-encode the input)
^^ the actual duration is 192ms - the thing seems to think in terms of 32ms chunks, so you can have either 160 or 192ms, but not 170 (32ms is also the shortest possible duration here, which is quite a lot when it comes to audio delays)Code:ffmpeg -f lavfi -i "anullsrc=channel_layout=stereo:sample_rate=48000" -b:a 224k -t 170ms silence.ac3
The resulting audio track is just as out of sync with the video as the original one.Code:ffmpeg -i "concat:silence.ac3|input.ac3" -acodec copy output.ac3
Method 2: adelay
Doesn't seem to have any effect, it is out of sync again.Code:ffmpeg -i input.ac3 -af "adelay=170ms:all=true" output.ac3
***
I must be doing something wrong here, but can't figure out what.
+ Reply to Thread
Results 1 to 13 of 13
-
-
@NikolaiYourin: If you just want a sync output stream you could use 'itsoffset' to delay the video stream. (see: https://www.ffmpeg.org/ffmpeg-all.html#Main-options)
I have used method 1 successfully in the past. What does your muxing call look like? (you did extract the video before and you are try to mux raw streams right?)
@ProWo: Does you gui allow to add silence or does it just add the delay upon muxing using "-itsoffset" ?users currently on my ignore list: deadrats, Stears555, marcorocchini -
I use 'eac3to' in your GUI UsEac3to ... or also 'ffmpeg' in 'a/v recode' button
eac3to:
[Attachment 55524 - Click to enlarge]
ffmpeg: add -af "adelay=160|160"
[Attachment 55525 - Click to enlarge]
[Attachment 55526 - Click to enlarge]Last edited by sekininsha; 15th Oct 2020 at 18:03.
責任者-MDX -
sekininsha,
I case you're not aware, and I don't know if all formats are supported this way, but for ac3 sources at least, if you don't specify a bitrate and the output is ac3, eac3to won't re-encode. It'll still add a delay by adding silent audio, but it doesn't re-encode the rest. The main difference is, without re-encoding, the delay can only be applied in increments the size of an audio frame, but it's close enough.
Edit: After posting I realised the bitrate specified in your screenshot was the same as the source bitrate, in which case eac3to shouldn't re-encode (unless you specify other options that force it to).
Without re-encoding:
Code:eac3to v3.34 command line: "C:\MeGUI\tools\eac3to\eac3to.exe" "E:\test.ac3" "E:\testing.ac3" 66ms ------------------------------------------------------------------------------ AC3, 5.1 channels, 0:21:35, 384kbps, 48kHz, dialnorm: -27dB Removing AC3 dialog normalization... Applying (E-)AC3 delay... A remaining delay of +2ms could not be fixed. Creating file "E:\testing.ac3"... eac3to processing took 2 seconds. Done.
[Attachment 55527 - Click to enlarge]
The same sort of thing applies when extracting audio from a container such as MKV.
I tend to use MeGUI's HD Streams Extractor for that. Eac3to will detect any container audio delay and remove it by adding silence as it extracts. It'll also fix any gaps in the audio stream by adding silence, should there be any.
[Attachment 55528 - Click to enlarge]Last edited by hello_hello; 15th Oct 2020 at 19:31.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Well, you would think something this straightforward would work without a hitch.
There is no raw video stream, I was going to fix the audio and then mux it back into the .MKV, but I didn't even get to the muxing stage - a quick check with MPC-HC revealed that the new audio track was out of sync.
That is not much different from my original command line #2. I just tried it and it did not seem to delay the audio one bit. -
-
I found that listing the video file twice on the line got me to understand better what I had to do to get the audio synced with the video.
This file, the audio leads the video (will be applying a 500m/s offset).
With two appearences of the same video on the command line(video 0 and video 1) the offset applies to the file listed after the offset command (in this case file 1)
Muxer uses the video from file 0 (which is simply copied) and the audio from file 1 which now has the offset.
ffmpeg -i bbt.mp4 -itsoffset 0.500 -i bbt.mp4 -vcodec copy -acodec copy -map 0:v -map 1:a output_bbt.mp4 -
Maybe something else within the .mkv is at fault here, I don't know what to think anymore. I have four versions of the audio track in question:
- the original built into the .mkv
- one with 192ms of silence prepended to it (ffmpeg / concat)
- another one with 352ms of silence
- and yet another one made with "delaycut -startdelay 192 -same input.ac3"
And the funny thing is that they are all out of sync by the same amount. Setting the delay to -170ms in MPC-HC brings all four of them in perfect sync with the video. Go figure. -
In case you did not extract the video stream before muxing, but use the mkv itself it might be a problem with time codes or 'stretch' flags,..
users currently on my ignore list: deadrats, Stears555, marcorocchini -
Something must be seriously wrong with that mkv. For the problem to go away, I had to extract all the elementary streams and mux a new mkv from scratch, without touching the original one. And that was enough to fix it - everything is in sync now, with no delays whatsoever.
Thank you all guys, and sorry for the noise.
Similar Threads
-
How do you add an audio delay in mkvtoolnix?.
By Felow in forum Newbie / General discussionsReplies: 6Last Post: 18th Sep 2020, 17:31 -
how to re-add original audio delay back into a 2-inputfile ffmpeg transcode
By hydra3333 in forum Newbie / General discussionsReplies: 0Last Post: 30th Jul 2020, 01:30 -
ffmpeg: Fixing delay during capture?
By esoul in forum Video Streaming DownloadingReplies: 0Last Post: 31st Mar 2018, 05:35 -
Delay audio track in AVI
By Patr1ck in forum ProgrammingReplies: 4Last Post: 13th Jan 2018, 10:33 -
How to add delay to .aac without re-encoding it?
By midts in forum AudioReplies: 6Last Post: 5th May 2017, 13:03