Setting PIDs for mpegtsmux

Peter Maersk-Moller pmaersk at gmail.com
Thu May 28 03:39:50 PDT 2015


Hi Jesper.

Thanks a million. Exactly the kind of granularity of control needed to mux
a couple of video streams into one ts stream and needed to demux them again.

Best regards
Peter MM

On Wed, May 27, 2015 at 2:20 PM, Jesper Larsen <knorr.jesper at gmail.com>
wrote:

> I'm not aware of any way of setting properties on child elements through
> gst-launch command.
>
> But you should be able to do the filtering using some tees, tsdemuxs, and
> decode bins.
> The tsdemux element creates src pads with names that includes the PID of
> the stream served on that pad.
>
> Imagine you have a program (10) with 1 video stream on PID 300, and two
> audio streams on PID 301, and 302.
>
> You should be able to play the video with one of the audio streams using
> something like:
>
> gst-launch-1.0 udpsrc ..... ! tsdemux program-number=10 name=d ! queue !
> decodebin ! autovideosink d.audio_012d ! queue ! decodebin ! autoaudiosink
>
> That should choose the program number 10, play the video, and play the
> audio on PID 301 (if it is part of the program). Note that the muxer uses
> dec numbers for the PID while the demuxer uses hex.
> If you need to decode several programs at the same time, you can put a tee
> element in just before the tsdemux, and do a second branch with tsdemux
>
> udpsrc ... ! tee name=t ! tsdemux program-number=10 name=d1 t. ! tsdemux
> program-number=11 name=d2 ....
>
> You can see the templates for the pad names running
> gst-inspect-1.0 tsdemux
>
> Jesper
>
>
>
> On Wed, May 27, 2015 at 11:12 AM, Peter Maersk-Moller <pmaersk at gmail.com>
> wrote:
>
>> Hi Jesper.
>>
>> Thanks for the info. Very helpful and very useful.
>>
>> Now for the other end, the consuming or decoding end. I assume I can do
>> something similar with tsdemux.
>>
>>   gst-launch-v udpsrc ..... ! mtsdemux program-number=10 ! .....
>>
>> Haven't tested it yet, but it'll be close I think.
>>
>> What if you want to control what program number to decode in a decodebin.
>> Is there a less known, less documented way to parse this information to
>> decodebin? I remember there is a way to set some parameters of a bin in
>> GStreamer, however I have never found the formal documentations for that.
>>
>> best regards.
>>
>> Peter Maersk-Moller
>>
>>
>>
>>
>> Is there a way to filter which PID gets decoded when using decodebin or
>> tsdemux
>>
>> On Wed, May 27, 2015 at 9:39 AM, Jesper Larsen <knorr.jesper at gmail.com>
>> wrote:
>>
>>> Well, my knowledge was just increased. You can actually set the prog-map
>>> preoperty using gst-launch
>>>
>>> gst-launch-1.0 -v videotestsrc name=vsrc1 is-live=true do-timestamp=true
>>> ! x264enc ! queue ! h264parse ! muxer.sink_300 mpegtsmux name=muxer
>>> prog-map=program_map,sink_300=10,sink_301=11 ! queue ! tcpserversink
>>> host=0.0.0.0 sync-method=2 recover-policy=keyframe port=5000  videotestsrc
>>> name=vsrc2 is-live=true do-timestamp=true ! x264enc ! queue ! h264parse !
>>> muxer.sink_301
>>>
>>> This will put the video on PID 300 on program number 10, and PID 301 on
>>> program 11.
>>>
>>> On Wed, May 27, 2015 at 8:12 AM, Jesper Larsen <knorr.jesper at gmail.com>
>>> wrote:
>>>
>>>> You can set the PID when requesting a sink pad from the mux. I.e.
>>>>
>>>> gst-launch-1.0 -v videotestsrc name=vsrc1 is-live=true
>>>> do-timestamp=true ! x264enc ! queue ! h264parse ! muxer.sink_300 mpegtsmux
>>>> name=muxer ! queue ! tcpserversink host=0.0.0.0 sync-method=2
>>>> recover-policy=keyframe port=5000  videotestsrc name=vsrc2 is-live=true
>>>> do-timestamp=true ! x264enc ! queue ! h264parse ! muxer.sink_301
>>>>
>>>> to use PID 300 and 301 instead.
>>>>
>>>> I'm afraid you cannot configure which PIDs belongs to which program/PMT
>>>> using gst-launch.
>>>> You need to set the "prog-map" property of the mpegtsmux element, which
>>>> takes a GstStructure, and to my knowledge you cannot specify a GstStructure
>>>> using gst-launch.
>>>>
>>>> An example of setting the two videostreams to specific program numbers
>>>> (3 and 4):
>>>>
>>>> GstElement *mux;
>>>> GstStructure *pm;
>>>>
>>>> mux = gst_element_factory_make ("mpegtsmux", NULL);
>>>>
>>>> pm = gst_structure_new_empty ("program_map");
>>>> gst_structure_set (pm, "sink_300", G_TYPE_INT, 3,
>>>>                            "sink_301", G_TYPE_INT, 4, NULL);
>>>> g_object_set (mux, "prog-map", pm, NULL);
>>>>
>>>> This will associate PID 300 to program 3, and PID 301 to program 4.
>>>> When you add the audio streams you simply give those a fixed PID as well,
>>>> and associate them with the program containing the correct video stream.
>>>>
>>>> Ad Astra.
>>>> Jesper
>>>>
>>>> On Tue, May 26, 2015 at 5:25 PM, Peter Maersk-Moller <pmaersk at gmail.com
>>>> > wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> When you are muxing multiple video streams with mpegtsmux, is there
>>>>> then a way to set/control (on the command line using gst-launch) the PIDs
>>>>> of video streams that the mpegtsmux chooses for each video stream?
>>>>>
>>>>> A quick test with the following command line reveals mpegtsmux chooses
>>>>> PID 65 and 66.
>>>>>
>>>>> gst-launch-1.0 -v videotestsrc name=vsrc1 is-live=true
>>>>> do-timestamp=true ! x264enc ! queue ! h264parse ! mpegtsmux name=muxer !
>>>>> queue ! tcpserversink host=0.0.0.0 sync-method=2 recover-policy=keyframe
>>>>> port=5000  videotestsrc name=vsrc2 is-live=true do-timestamp=true ! x264enc
>>>>> ! queue ! h264parse ! muxer.
>>>>>
>>>>> Assuming you have audio as well, is there a way to set/control which
>>>>> audio stream belongs to which video stream (for PAD/PMT) ?
>>>>>
>>>>> Best regards
>>>>> Peter MM
>>>>>
>>>>> _______________________________________________
>>>>> gstreamer-devel mailing list
>>>>> gstreamer-devel at lists.freedesktop.org
>>>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> gstreamer-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>
>>>
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>
>>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150528/e40bdf00/attachment-0001.html>


More information about the gstreamer-devel mailing list