【问题标题】:Getting rtmp streams in GStreamer, creating a mosaic and sending the resulting rtmp在 GStreamer 中获取 rtmp 流,创建马赛克并发送生成的 rtmp
【发布时间】:2018-09-27 18:04:08
【问题描述】:

我运行以下代码

gst-launch-1.0 -e \ 视频混音器名称=混合\ sink_0::xpos=0 sink_0::ypos=0 sink_0::alpha=0\ sink_1::xpos=0 sink_1::ypos=0 \ 水槽_2::xpos=200 水槽_2::ypos=0 \ sink_3::xpos=0 sink_3::ypos=100 \ 水槽_4::xpos=200 水槽_4::ypos=100 \ rtmpsrc location='rtmp://streaming.example.com:1935/209147924'\ !解码器!视频转换!视频缩放\ !视频/x-raw,宽度=200,高度=100 \ ! mix.sink_1 \ rtmpsrc location='rtmp://streaming.example.com:1935/209147925'\ !解码器!视频转换!视频缩放\ !视频/x-raw,宽度=200,高度=100 \ ! mix.sink_2 \ rtmpsrc location='rtmp://streaming.example.com:1935/209147926'\ !解码器!视频转换!视频缩放\ !视频/x-raw,宽度=200,高度=100 \ ! mix.sink_3 \ rtmpsrc location='rtmp://streaming.example.com:1935/209147927'\ !解码器!视频转换!视频缩放\ !视频/x-raw,宽度=200,高度=100 \ ! mix.sink_4 \ 混合。 !队列 !视频转换! x264enc ! flvmux 可流=真!队列 ! rtmpsink location='rtmp://streaming.example.com:1935/test'

谢谢。我们用马赛克解决了这个问题。这是工作版本。

【问题讨论】:

  • 添加最后一行时出错

标签: gstreamer rtmp


【解决方案1】:

有两个问题。

1) 主要问题是“videomixer”只有一个 src pad。您将它连接到两个焊盘。 -

gst-launch-1.0 -e \

    videomixer name=mix \
            sink_0::xpos=0   sink_0::ypos=0  sink_0::alpha=0\
            sink_1::xpos=0   sink_1::ypos=0 \
            sink_2::xpos=200 sink_2::ypos=0 \
            sink_3::xpos=0   sink_3::ypos=100 \
            sink_4::xpos=200 sink_4::ypos=100 \
        ! xvimagesink 

通过这样做,您将 videomixer src_pad 连接到 Sixvimagesink 的 sink pad

最后,您再次尝试使用队列和其他元素将 videomixer src_ 连接到 rtmpsink。

所以你必须删除其中一个连接。

如果您不想连接到 xvimagesink,只需删除“!xvimagesink”

如果您不想连接到 rtmpsink,请删除“混合!队列!视频转换 ...”部分。

2) 如果要保留与队列的连接,则存在以下问题。 您正在将 mix.sink_4 连接到 mix.src。

... ! mix.sink_4 \
        ! mix. ! queue ! videoconvert ! ...

删除第一个“!”和 ”。”在最后一行。

... ! mix.sink_4 \
         mix ! queue ! videoconvert ! ...

那么它应该不会给出语法错误。

编辑 1

我再次认为你犯了一个错误。您正在将 mix 的 src 连接到 mix.sink_0。我已经更正了。

gst-launch-1.0 -e \
    videomixer name=mix \
            sink_0::xpos=0   sink_0::ypos=0  sink_0::alpha=0\
            sink_1::xpos=0   sink_1::ypos=0 \
            sink_2::xpos=200 sink_2::ypos=0 \
            sink_3::xpos=0   sink_3::ypos=100 \
            sink_4::xpos=200 sink_4::ypos=100 \
      \    /* You should not add "! .mix.sink_0" here. */
    rtmpsrc location='rtmp://streaming.example.com:1935/209147924'\
        ! decodebin ! videoconvert ! videoscale \
        ! video/x-raw,width=200,height=100 \
        ! mix.sink_1 \
    rtmpsrc location='rtmp://streaming.example.com:1935/209147925'\
        ! decodebin ! videoconvert ! videoscale \
        ! video/x-raw,width=200,height=100 \
        ! mix.sink_2 \
    rtmpsrc location='rtmp://streaming.example.com:1935/209147926'\
        ! decodebin ! videoconvert ! videoscale \
        ! video/x-raw,width=200,height=100 \
        ! mix.sink_3 \
    rtmpsrc location='rtmp://streaming.example.com:1935/209147927'\
        ! decodebin ! videoconvert ! videoscale \
        ! video/x-raw,width=200,height=100 \
        ! mix.sink_4 \
        mix ! queue ! videoconvert ! x264enc ! flvmux streamable=true ! queue ! rtmpsink location='rtmp://streaming.example.com:1935/test'

让我在这里提供一些有关“name=”用法的信息。 您可以在 gstreamer 管道中命名一个元素并使用它来构建管道。它主要用于复杂的管道。让我用一个简单的管道来展示它的用法。

假设以下是所需的管道:

 srcelem ! elem1 ! elem2 ! elem3 ! sinkelem

可以写成下面这样。

elem2 name=named_elem \    /* Naming elem2 */
named_elem ! elem3 ! sinkelem \     /* Connecting elem2 to downstream pipeline part. Note that there is no "!" before "named_elem" */
srcelem ! elem1 ! named_elem /* Connecting elem2 to upstream pipeline part. Note that there is no "!" after "named_elem" */

如果你仔细阅读,它会构造与前面提到的相同的管道。

【讨论】:

  • 语法错误丢失。出现另一条错误消息。请告诉我,可能是什么问题? WARNING: erroneous pipeline: could not link mix to queue0网络上用rtmp拼接的例子,没找到。
  • @user2306100 还有更多问题。编辑了我的答案。
  • 不带“.”写WARNING: erroneous pipeline: no element "mix"
  • 我编辑了问题中的代码。新错误。 WARNING: erroneous pipeline: no element "mix"哪里有错误?
  • 谢谢。与“。”一起使用。 ! mix.sink_4 \ mix. ! queue ! videoconvert 我以为我正在将声音与流混合。你能告诉我如何在马赛克中从 rtmp 发出声音吗?
猜你喜欢
  • 2016-12-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-02
  • 1970-01-01
  • 2020-07-07
  • 1970-01-01
相关资源
最近更新 更多