Log in

View Full Version : Delay audio by decding with FFMPEG and / or fill up end with silence


mbcd
16th May 2019, 13:52
Not found some correct or working commands.

Which command do I need to delay (positiv/negative) an audio stream I am decoding into another format (uncompressed).
There is no video inside, only audio.

And appended question:
Is there a way to fill up the end of this audio with silence to some defined total-length of audiostream or trim it to that total-length:

1:27min real-length
1:30min wanted total-length
0:03min silence added to end

1:36min real-length
1:30min wanted total-length
0:06min trimmed from end

sneaker_ger
16th May 2019, 14:42
Which command do I need to delay (positiv/negative) an audio stream I am decoding into another format (uncompressed).
Positive 2.5 seconds try: -itsoffset 2.5
Negative 2.5 seconds try: -ss 00:02.500


And appended question:
Is there a way to fill up the end of this audio with silence to some defined total-length of audiostream or trim it to that total-length:

1:27min real-length
1:30min wanted total-length
0:03min silence added to end
Try: -longest

1:36min real-length
1:30min wanted total-length
0:06min trimmed from end
Try: -shortest

mbcd
16th May 2019, 14:58
Thank you very much for this hints, but they not seem to work.

-itsoffset does not make any change, a "10.0" should give a 10 second delay, but nothing is applied, its still exact like the original. This command seems only to work if you have a container and sync video with audio.

-ss works, but thats only the trimming part at beginning.

-longest / shortest needs seperate streams as input as i suggest. I have only one single stream and wand to apply silense at the end or trim the end.

I tried with flac and wav as output, input is dts or ac3.

BTW: using Windows!

sneaker_ger
16th May 2019, 23:56
I see.

For delay (silence at beginning) try adelay filter (https://ffmpeg.org/ffmpeg-filters.html#adelay). For silence at end try apad filter (https://ffmpeg.org/ffmpeg-filters.html#apad). To cut short use -to (https://trac.ffmpeg.org/wiki/Seeking) (similar to -ss).



P.S.: delaycut (https://github.com/darealshinji/delaycut/releases) can losslessly do such operations on ac3 and dts, and it is easy to use. Maybe it is of interest to you.

mbcd
17th May 2019, 21:30
Thank you very much for your time, you were faster ... :-)

I came to the same conclusion, apad and adelay with apad=whole_dur there is a wonderfull command to define the total playtime.

For delay you have to specify each channel seperate, this is possible but "bad", but not a big problem, but you have to know the amount of channels before, dont unsterstand why there is no general delay for all channels.

-t is also possible for trimming to a total length.


delaycut looks nice, but I convert it to wave, also it should not be possible to cut dts-ma with it, but a nice hint, some years passed since I used it last time, is a great program!

sneaker_ger
18th May 2019, 08:48
For delay you have to specify each channel seperate, this is possible but "bad", but not a big problem, but you have to know the amount of channels before, dont unsterstand why there is no general delay for all channels.
Yes, it's very .. peculiar.

But at least:
You can use adelay='5|5|5|5|5|5|5|5|5'.. up to very high number.
Unused entries are ignored.
https://trac.ffmpeg.org/ticket/5855#comment:4

Logan9778
14th December 2019, 07:34
This is what I got from Superuser.com on the internet. How to input an audio delay in FFMpeg.

ffmpeg.exe -i "movie.mp4" -itsoffset 3.84 -i "movie.mp4" -map 0:v -map 1:a -c copy "movie-audio-delayed.mp4" #this will offset the audio by 3.84 seconds.

Put it in my FFMpeg script to convert to xvid and mp3.

"C:\Users\jack5\OneDrive\Desktop\ffmpeg\bin\ffmpeg.exe" -i "D:\Avisynth Scripts\Donald Duck 1\title08.xvid.avs" -itsoffset -0.197 -i "D:\Avisynth Scripts\Donald Duck 1\title08.xvid.avs" -map 0:v -map 1:a -vf "setsar=1/1" -c:v libxvid -vtag xvid -gmc 1 -me_quality 6 -mbd rd -variance_aq 1 -qscale:v 5 -c:a libmp3lame -b:a 128k "C:\Users\jack5\Videos\Final\Donald's Better Self test.avi"

Seems to work, but it's hard to completely tell with the cartoons I'm working on right now.

tebasuna51
14th December 2019, 11:39
@Logan9778

Like mbcd say the -itsoffset parameter only add a delay over the audio track in a container.
To delay audio inserting silence at the begining you can use adelay with the new sintax for all channels:

-af adelay=delays=2500:all=1

It is possible also delay many audio streams without decode with eac3to (better than delaycut).

Logan9778
16th December 2019, 00:09
Ah, cool.

So, this would set it to 0 delay, since your filling in silence at the beginning, right? Then I wouldn't have to worry about the delay anymore, which would be nice.