4

I have two live audio streams, they both are MONO streams. Now I want these two streams to merge in one stream and output to single new stream.

I am merging two input streams with following command:

ffmpeg -i rtmp://myIp:1935/live/stream1 -i rtmp://myIp:1935/live/stream2 -codec:a aac -strict -2 -filter_complex "[0:a][1:a]amerge" -f flv rtmp://myIp:1935/live/myStream

The above command works but when I listen to new stream i.e. myStream, both streams are able to listen but in separate channel. Means stream1 is only in Left channel and stream2 is only in Right channel.

What I want is, both input stream stream1 and stream2 should be available to both the channels (Left & Right).

I have tried lot but can't get success and I am not good at ffmpeg also. So Is there anyone who can help me in this ???

Output of my consol:

ffmpeg version 1.0.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec  5 2012 21:11:26 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[flv @ 0x7fb85c01e200] max_analyze_duration 5000000 reached at 5008000
[flv @ 0x7fb85c01e200] Could not find codec parameters for stream 0 (Video: none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[flv @ 0x7fb85c01e200] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://192.168.0.62:1935/live/stream1':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: none, 1k tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: nellymoser, 16000 Hz, mono, flt
[flv @ 0x7fb85c01aa00] max_analyze_duration 5000000 reached at 5024000
[flv @ 0x7fb85c01aa00] Could not find codec parameters for stream 0 (Video: none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[flv @ 0x7fb85c01aa00] Estimating duration from bitrate, this may be inaccurate
Input #1, flv, from 'rtmp://192.168.0.62:1935/live/stream2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: none, 1k tbr, 1k tbn, 1k tbc
    Stream #1:1: Audio: nellymoser, 16000 Hz, mono, flt
[Parsed_amerge_0 @ 0x7fb85bc21d20] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, flv, to 'rtmp://192.168.0.62:1935/live/myStream':
  Metadata:
    encoder         : Lavf54.29.104
    Stream #0:0: Audio: aac ([10][0][0][0] / 0x000A), 16000 Hz, stereo, flt, 128 kb/s
Stream mapping:
  Stream #0:1 (nellymoser) -> amerge:in0
  Stream #1:1 (nellymoser) -> amerge:in1
  amerge -> Stream #0:0 (aac)
Press [q] to stop, [?] for help

1 Answer 1

4

Change amerge to amix to mix the inputs together into the same channel. Then add -ac 2 after that to produce 2-channel stereo output.

ffmpeg -i rtmp://myIp:1935/live/stream1 -i rtmp://myIp:1935/live/stream2 -codec:a aac -strict -2 -filter_complex "[0:a][1:a]amix" -ac 2 -f flv rtmp://myIp:1935/live/myStream
4
  • @mark40 It's working fine, now if I want to delay stream1 by some second then how can I achieve this? I have tried using -itsoffset with no success (Both are only audio streams).
    – Yuvrajsinh
    Jun 13, 2014 at 7:29
  • 1
    @Yuvrajsinh: If you use -itsoffset place it before the -i option for the input you want to adjust. Alternatively try the adelay filter, e.g. [0:a]adelay=3000[delay0];[delay0][1:a]amix
    – mark4o
    Jun 13, 2014 at 21:32
  • @mark40 Thanks for delay help it's working. Now when I give delay for stream2 It is not consistence, means if I run command one time and then second time then delay between stream changes every time so I have to change delay accordingly and I can't understand how to manage that.
    – Yuvrajsinh
    Jun 16, 2014 at 13:26
  • 1
    If you have more questions then add a new Question, not a comment.
    – mark4o
    Jun 16, 2014 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .