View Full Version : FFMPEG - join ES - shift audio
NoX1911
26th April 2014, 01:26
Hallo,
i have 5 elementary streams and 5 audio files:
1.264, 2.264, 3.264, 4.264, 5.264
1.aac, 2.aac, 3.aac, 4.aac, 5.aac
I want to join/mux them and add +50ms audio shift to every following audio file (1.aac 0ms, 2.aac +50ms, 3.aac +100ms, 4.aac +150ms, 5.aac +200ms).
Anyone know how to do this with ffmpeg?
Selur
26th April 2014, 12:15
In theory: yes.
I have never tried this for aac (only for ogg vorbis ac3 and mp3) or with multiple files in one call, but it should work, like this:
a. load all files using '-i PATHTOFILE'
b. for each audio stream use filter_complex and some magic to do something like:
-filter_complex "aevalsrc=0:0:0:0:0:0::d=0.138:sample_ rate=48000[silence];[silence][0:a]concat=n=2:v=0:a=1[out]" -map [out] -c:a ac3 -ab 384000
this adds 138ms of delay to a six channel ac3 stream.
you should read up on ffmpgs filter_complex to really understand:
a. how the line I posted works
and
b. how to adapt it to your problem
Have fun!
Cu Selur
NoX1911
26th April 2014, 21:58
Thanks for that, but 'filter_complex' can't 'stream copy' if i'm right. Maybe not optimal...
I think i've found another solution. The audio shift per file seems to be caused by the ADTS header (https://www.ffmpeg.org/ffmpeg-bitstream-filters.html#aac_005fadtstoasc) (or other header data - see below) that can be removed by bitstream filter. If i use that with a global audio shift by +100ms (interleave shift?) it seems to be ok now.
This is my current command line:
ffmpeg -y -i "concat:g:\1.264|g:\2.264|g:\3.264|g:\4.264|g:\5.264" -i "concat:g:\1.aac|g:\2.aac|g:\3.aac|g:\4.aac|g:\5.aac" -bsf:a aac_adtstoasc -c copy e:\video.mp4
Edit: I joined the files previously with 'copy /b'. I think that's ok for H.264 elementary streams but not for AAC.
The files are broadcasted FLVs. I couldn't join them directly with ffmpeg (timecode errors: pts < dts).
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.