Encode and mux GStreamer pipeline into MPEG-TS

1.4k views Asked by At

I'm trying to encode and mux GESPipeline into MPEG-TS for streaming over UDP.
The pipeline plays fine on screen in preview mode.
My attempt, essentially:

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);

In output with GST_DEBUG=3:

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

Update: more detailed debug reveals that it actually looks into mpegtsmux, but skips it. Why?
Relevant messages:

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 ...

If I change video/mpegts to video/x-matroska, mkv file is produced (though ugly and without sound).

How to encode into mpegts?

1

There are 1 answers

0
sa7 On BEST ANSWER

The problem was missing fields listed in src caps in gst-inspect-1.0 mpegtsmux. Those are required and if you don't specify them it won't match the muxer.

Solution for mpegtsmux:

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

Thanks to Freenode #gstreamer IRC channel.