将 GStreamer 管道编码和复用到 MPEG-TS

Encode and mux GStreamer pipeline into MPEG-TS

我正在尝试将 GESPipeline 编码并复用到 MPEG-TS 中以通过 UDP 进行流式传输。
管道在预览模式下在屏幕上播放良好。
我的尝试,本质上是:

GstEncodingContainerProfile *prof;
GstCaps *caps;
caps = gst_caps_from_string("video/mpegts");
prof = gst_encoding_container_profile_new("test-app-profile", NULL, caps, NULL);
caps = gst_caps_from_string("video/x-h264");
gst_encoding_container_profile_add_profile(prof,
    (GstEncodingProfile*) gst_encoding_video_profile_new(caps, NULL, NULL, 0));
caps = gst_caps_from_string("audio/x-ac3");
gst_encoding_container_profile_add_profile(prof,
    (GstEncodingProfile*) gst_encoding_audio_profile_new(caps, NULL, NULL, 0));
// this fails:
ges_pipeline_set_render_settings (pl, "file:///path/out.ts", prof);

在 GST_DEBUG=3 的输出中:

encodebin gstencodebin.c:1976:create_elements_and_pads: error: No available muxer for format video/mpegts

更新: 更详细的调试显示它实际上查看了 mpegtsmux,但跳过了它。为什么?
相关留言:

gst_encode_bin_setup_profile: Setting up profile 0x557c3c98c460:test-app-profile (type:container)
create_elements_and_pads: Current profile : test-app-profile
_get_muxer: Getting list of muxers for format video/mpegts
gst_element_factory_list_filter: finding factories
...
gst_element_factory_list_filter: Trying mpegtsmux
gst_structure_parse_field: trying field name 'systemstream'
_priv_gst_value_parse_value: trying type name 'boolean'
gst_structure_parse_field: trying field name 'packetsize'
_priv_gst_value_parse_value: trying type name 'int'
... tries other muxers ...

如果我把video/mpegts改成video/x-matroska,就会生成mkv文件(虽然丑陋而且没有声音)。

如何编码成mpegts?

问题是缺少 gst-inspect-1.0 mpegtsmux 中 src caps 中列出的字段。 这些是必需的,如果您不指定它们,它将与 muxer 不匹配。

mpegtsmux 的解决方案:

gst_caps_from_string("video/mpegts, systemstream=true, packetsize=188");

感谢 Freenode #gstreamer IRC 频道。