[FFmpeg-user] Muxing multiple files and concatenating those outputs

Greg Oliver oliver.greg at gmail.com
Wed Apr 22 05:29:46 EEST 2020


On Thu, Apr 16, 2020 at 10:19 AM Nicolas George <george at nsup.org> wrote:

> Greg Oliver (12020-04-14):
> > We currently use ffmpeg to combine 2 streams (telephony codecs) into
> > mp3/wav/flac, etc..  This is no problem - we use:
> >
> > ffmpeg -ar 8000 -y -f mulaw -i calls/example.g711a.ulaw -ar 8000 -f mulaw
> > -i calls/example.g711b.ulaw -filter_complex "[0:a][1:a]amerge[aout]" -map
> > "[aout]" output.wav
> >
> > If we have multiple legs of a recording, we just use linux `cat' to
> > concatenate them prior to ffmpeg processing (we have raw audio frames
> > without headers, etc, so this works fine).
> >
> > Due to Covid, almost all of our customers have moved their call centers
> to
> > employee homes, so we have mixed codec calls and the necessity has arose
> to
> > generate audio files accordingly.  It is easily accomplished with
> multiple
> > temporary files, but I would like to clean it up and have been
> unsuccessful
> > in coming up with a single string to accomplish it.
> >
> > Example using these files (suffix denotes codec - a and b are each side
> of
> > a call):
> >
> > 18_17_248.g729a
> > 18_17_248.g729b
> > 19_18_440.g711a
> > 19_18_440.g711b
> > 20_01_886.g729a
> > 20_01_886.g729b
> >
> > Current method to concatenate and transcode to wav putting caller on left
> > and callee on right:
> >
> > ffmpeg -f g729 -i 18_17_248.g729a -f g729 -i 18_17_248.g729b
> > -filter_complex "[0:a][1:]amerge[aout]" -map "[aout]" out_1.wav
> >
> > ffmpeg -ar 8000 -y -f mulaw -i 19_18_440.g711a -ar 8000 -f mulaw -i
> > 19_18_440.g711b -filter_complex "[0:a][1:a]amerge[aout]" -map "[aout]"
> > out_2.wav
> >
> > ffmpeg -f g729 -i 20_01_886.g729a -f g729 -i 20_01_886.g729b
> > -filter_complex "[0:a][1:]amerge[aout]" -map "[aout]" out_3.wav
> >
> > ffmpeg out_1.wav out_2.wav out_3.wav final.wav
> >
> > My goal is to syntactically accomplish this with one ffmpeg string (not
> > pipes, ; or && bash syntax).
> >
> > I would appreciate any insight - I have tried everything I can find /
> think
> > of without success.
>
> I suspect what you need is the concat filter. But you were not clear
> enough about what exactly you are trying to achieve. Maybe make diagram?
>
> Regards,
>
> --
>   Nicolas George


I ended up just keeping it as a script and getting the developers to
incorporate it into our code.  Thanks though!  Since it is a script, a
single bash call is not too intrusive.  If we had some C programmers, I
would have them use the ffmpeg libraries directly, but they are all just
java heads..

-Greg


More information about the ffmpeg-user mailing list