[FFmpeg-user] Howto sync two audio streams and mix them

Thomas Seilund tps at netmaster.dk
Sat Apr 18 09:38:20 CEST 2015


Hi all

I have an mpegts container with one video and two audio streams.

I what to mix the two audio streams. At the same time the second audio  
stream must be delayed 10 seconds to match the first audio stream.

Here is what I have as input

tps at t420:~/video/test$ ffprobe -i 20150416203941.broadcast.ts
ffprobe version N-69238-g2699a37 Copyright (c) 2007-2015 the FFmpeg  
developers
   built on Feb 24 2015 18:13:15 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
   configuration: --enable-gpl --enable-libmp3lame --enable-libvpx --enable- 
libx264 --enable-version3 --enable-libvorbis --enable-libfreetype --enable- 
libv4l2 --enable-libfdk-aac --enable-nonfree --enable-libpulse
   libavutil      54. 17.100 / 54. 17.100
   libavcodec     56. 20.100 / 56. 20.100
   libavformat    56. 19.100 / 56. 19.100
   libavdevice    56.  4.100 / 56.  4.100
   libavfilter     5.  8.101 /  5.  8.101
   libswscale      3.  1.101 /  3.  1.101
   libswresample   1.  1.100 /  1.  1.100
   libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from '20150416203941.broadcast.ts':
   Duration: 00:00:18.69, start: 1.400000, bitrate: 4186 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] /  
0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50  
tbc
     Stream #0:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,  
stereo, s16p, 384 kb/s
     Stream #0:2[0x102]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,  
stereo, s16p, 384 kb/s
tps at t420:~/video/test$



Here is what I do

ffmpeg -y -i 20150416203941.broadcast.ts -itsoffset 10 -i  
20150416203941.broadcast.ts -filter_complex "[0:1][1:2]amix[mixout]" -c:v  
copy -c:a aac -b:a 128k -ar 44100 -strict -2 -map 0:0 -map [mixout] -f flv  
test1.flv



The two audio streams are mixed ok but the timestamps of the second audio  
stream are not shifted 10 seconds.



Actually, the following command without the -itsoffset 10 parameter  
produces the same output

ffmpeg -y -i 20150416203941.broadcast.ts -i 20150416203941.broadcast.ts - 
filter_complex "[0:1][1:2]amix[mixout]" -c:v copy -c:a aac -b:a 128k -ar  
44100 -strict -2 -map 0:0 -map [mixout] -f flv test2.flv



What am I doing wrong?

Any help would be appreciated.

Thanks

Thomas S


More information about the ffmpeg-user mailing list