【问题标题】:How can I merge two input rtp streams in ffmpeg?如何在 ffmpeg 中合并两个输入 rtp 流?
【发布时间】:2017-01-17 14:58:23
【问题描述】:

我想要两个合并两个 mp3 输入 rtp 流并将它们保存为 mp3 文件,使用以下命令:

ffmpeg -i rtp://127.0.0.1:5004?listen -i rtp://127.0.0.1:5005?listen -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame q:a 4 output.mp3

返回错误 bind failed: Error number -10048 发生 rtp://127.0.0.1:5005?listen: I/O error

在我尝试这个之前,我首先尝试将两个 mp3 文件与以下工作命令合并在一起:

ffmpeg -i input01.mp3 -i input02.mp3 -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame -q:a 4 output.mp3

我还尝试单独获取每个 rtp 流并创建一个 .wav 文件输出。这也适用于以下命令:

ffmpeg -i rtp://127.0.0.1:5004?listen output.wav  

使用 udp 我可以将流合并到一起并创建 mp3 输出:

ffmpeg -i udp://127.0.0.1:5004?listen -i udp://127.0.0.1:5005 -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame -q:a 4 output.mp3

有谁知道如何在 ffmpeg 中抓取、合并并写入 mp3 文件中的两个 rtp 流?还是像 2012 年一样只支持一个 rtp 流?

【问题讨论】:

    标签: ffmpeg stream rtp


    【解决方案1】:

    上述命令的一个问题是端口号。如果您在某个端口(通常在大于 1024 的偶数端口)上接收 rtp,则下一个更大的端口用于 rtcp。

    如果您为第二个流使用端口,该命令有效,该端口尚未被其他东西(如 rtcp)使用。

    ffmpeg -i rtp://127.0.0.1:5004?listen -i rtp://127.0.0.1:5006?listen -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame -q:a 4 output.mp3
    

    如果你想对原始音频做同样的事情,你可能会收到如下错误:

    Unable to receive RTP payload type 96 without an SDP file describing it. 
    

    要解决这个问题,您必须创建具有 rtp 负载类型、编解码器和采样率的 sdp 文件,并将这些文件用作 ffmpeg 输入。

    SDP 示例:

    v=0
    c=IN IP4 127.0.0.1
    m=audio 2002 RTP/AVP 96
    a=rtpmap:96 L16/16000
    

    在 FFmpeg 中使用 sdp 文件作为输入:

    ffmpeg -i a.sdp -i b.sdp -filter_complex ...
    

    【讨论】:

      猜你喜欢
      • 2010-10-20
      • 2020-12-31
      • 2019-06-26
      • 1970-01-01
      • 2017-04-11
      • 2013-03-16
      • 2017-08-11
      • 2019-03-05
      • 2021-09-27
      相关资源
      最近更新 更多