Use input-selector with filesrc elements on input

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Use input-selector with filesrc elements on input

Petr
Hi,
I would like to be able (in a program written in C) to switch between two different MP4 videos
using input-selector and send the output it to RTMP. Switching would be triggered by a user action.

I can start the first video, I can see it, but after an attempt to switch to the other source the stream
ends (looks like it reached the end of the file). I am trying to use just "active-pad" property to switch.
Using this method I can select the source before the start but not after playing is started.

I found some old posts (2010), people were not able to make it working (using Gstreamer 0.10),
for instance
http://gstreamer-devel.966125.n4.nabble.com/Switching-two-video-sources-with-input-selector-td2966941.html#a2969452

I am using GStreamer 1.8.2. Can anybody confirm/regret it should work? Or maybe even give some
direction how to achieve the described scenario?

Thank you, Petr

P.S. I am not posting any details now, I would just like to know it is possible,
maybe to get some sample.
Reply | Threaded
Open this post in threaded view
|

Re: Use input-selector with filesrc elements on input

Sebastian Dröge-3
On Tue, 2016-08-30 at 05:33 -0700, Petr wrote:

> Hi, 
> I would like to be able (in a program written in C) to switch between two
> different MP4 videos 
> using input-selector and send the output it to RTMP. Switching would be
> triggered by a user action. 
>
> I can start the first video, I can see it, but after an attempt to switch to
> the other source the stream
> ends (looks like it reached the end of the file). I am trying to use just
> "active-pad" property to switch.
> Using this method I can select the source before the start but not after
> playing is started.
>
> I found some old posts (2010), people were not able to make it working
> (using Gstreamer 0.10),
> for instance 
> http://gstreamer-devel.966125.n4.nabble.com/Switching-two-video-sources-with-input-selector-td2966941.html#a2969452
>
> I am using GStreamer 1.8.2. Can anybody confirm/regret it should work? Or
> maybe even give some direction how to achieve the described scenario?
You need to demux the MP4, and parse the audio/video stream before the
input-selector. Then it should work, assuming the configuration of both
streams is compatible and compatible with the server.

As RTMP is very picky about such details, you might only have luck when
re-encoding the stream.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Use input-selector with filesrc elements on input

Petr
Sebastian Dröge-3 wrote
On Tue, 2016-08-30 at 05:33 -0700, Petr wrote:
> Hi, 
> I would like to be able (in a program written in C) to switch between two
> different MP4 videos 
> using input-selector and send the output it to RTMP. Switching would be
> triggered by a user action. 
>
> I can start the first video, I can see it, but after an attempt to switch to
> the other source the stream
> ends (looks like it reached the end of the file). I am trying to use just
> "active-pad" property to switch.
> Using this method I can select the source before the start but not after
> playing is started.
>
> I found some old posts (2010), people were not able to make it working
> (using Gstreamer 0.10),
> for instance 
> http://gstreamer-devel.966125.n4.nabble.com/Switching-two-video-sources-with-input-selector-td2966941.html#a2969452
>
> I am using GStreamer 1.8.2. Can anybody confirm/regret it should work? Or
> maybe even give some direction how to achieve the described scenario?

You need to demux the MP4, and parse the audio/video stream before the
input-selector. Then it should work, assuming the configuration of both
streams is compatible and compatible with the server.

As RTMP is very picky about such details, you might only have luck when
re-encoding the stream.
Thank you for the advice, it solved the problem of output stream ending after switching.

Just for the record (for people reading archives), the whole chain (gstreamer based program sending RTMP to Wowza and watching it by VLC) still does not work well, the output stream is blocked for a few second after switching, sometimes it looks like the key frame of the new source
is not used, maybe there is some problem with timing. I need to examine it more in detail.

P.
Reply | Threaded
Open this post in threaded view
|

Re: Use input-selector with filesrc elements on input

Arjen Veenhuizen
If you're not switching on a keyframe boundary, that behaviour is to be expected. You can check the GST_BUFFER_FLAG_DELTA_UNIT (https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBuffer.html#GstBufferFlags) to see if a frame (GstBuffer) is a key frame.