Gstreamer、rtspsrc 和有效载荷类型

Han*_* R. 3 rtp rtsp gstreamer

我在从特定相机检索 rtsp 流时遇到困难,因为相机提供的 rtp 有效载荷类型为 35(未分配),并且rtph264depay插件接受的有效载荷类型在 [96-127] 范围内。结果是 gstreamer 显示如下错误:

<udpsrc0> error: Internal data flow error.
<udpsrc0> error: streaming task paused, reason not-linked (-1)
Run Code Online (Sandbox Code Playgroud)

我测试过的其他相机正在工作,因为它们定义了良好的有效载荷类型。

FFmpeg、MPlayer 和其他工具播放流,尽管它们可能会显示未知类型的警告,例如在 Mplayer 中:

rtsp_session: unsupported RTSP server. Server type is 'unknown'
Run Code Online (Sandbox Code Playgroud)

在 gstreamer 中是否有任何方法可以伪造有效负载类型、忽略不匹配的属性、强制插件之间的链接或以其他方式为我的问题创建解决方法?

我正在使用的管道是:

gst-launcg-0.10 rtspsrc location="..." ! rtph264depay ! capsfilter caps="video/x-h264,width=1920,height=1080,framerate=(fraction)25/1" ! h264parse ! matroskamux ! filesink location="test.mkv"
Run Code Online (Sandbox Code Playgroud)

Han*_* R. 5

我想通了,让它工作。在这里发布答案,希望它可以使某人受益。那里有多个类似的问题,但它们缺乏正确的答案。

以下是诀窍:

GstElement* depay = gst_element_factory_make("rtph264depay", "video_demux");
assert(depay);
GstPad* depay_sink = gst_element_get_static_pad(depay, "sink");
GstCaps* depay_sink_caps = gst_caps_new_simple("application/x-rtp",
        "media", G_TYPE_STRING, "video",
        "encoding-name", G_TYPE_STRING, "H264",
        NULL);
gst_pad_use_fixed_caps(depay_sink);
gst_pad_set_caps(depay_sink, depay_sink_caps);
gst_object_unref(depay_sink);
Run Code Online (Sandbox Code Playgroud)

它覆盖了rtph264depay插件的sink pad caps以减少限制,现在它接受任何有效载荷类型(和任何时钟速率),只要它是rtp并且具有H.264编码。

我认为 gst-launch 不可能做到这一点。