ffmpeg:将两个单声道实时音频流合并为单个立体声流

ffmpeg:将两个单声道实时音频流合并为单个立体声流

我有两个实时音频流,它们都是单声道流。现在我想将这两个流合并为一个流并输出到单个新流。

我正在使用以下命令合并两个输入流:

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

上述命令有效,但是当我收听新流时myStream,即两个流都可以收听,但是在独立通道。 方法流1仅在左声道流2仅在右通道

我想要的是,输入流 stream1 和 stream2 都应该可用于两个通道(左和右)。

我尝试了很多,但都没有成功,而且我也不擅长ffmpeg也。那么有谁能帮我吗???

我的控制台的输出:

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

更改amergeamix将输入混合到同一声道。然后添加-ac 2以产生 2 声道立体声输出。

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

相关内容