Using input-selector to change between multiple cameras for h264 encoding

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

Using input-selector to change between multiple cameras for h264 encoding

dlw
I have the following pipeline with 2 cameras at different
resolutions,framerates,formats etc.

cam1(1080p, 30fps) -> videoconvert -> videorate ->capsfilter ->
input-selector.sink_0

cam2(640, 10fps) -> videoconvert -> videorate ->capsfilter ->
input-selector.sink_1

input-selector -> h264enc ->rtph264pay -> udpsink

Running either input (sink_0, or sink_1) runs fine and streams correctly,
but if I try switching while the pipeline is running the image freezes and I
can't see a camera feed.

I switch pads on the input-selector using the following:
g_object_set(G_OBJECT(bindata->input-selector), "active-pad", new_pad,
NULL);

Is there something else I need to do to the pipeline to get the stream to
work?  The pipeline also runs fine if I put the h264enc before the
input-selector, but I get some image corruption during camera switches due
to not switching on an I-frame.  I'd prefer not to use this method because I
don't want to be running multiple hw encoders at the same time.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
dlw
Reply | Threaded
Open this post in threaded view
|

Re: Using input-selector to change between multiple cameras for h264 encoding

dlw
Its probably important to note that cam2 comes from appsrc, where I'm
manually setting buffer->pts to GST_CLOCK_TIME_NONE, so I'm probably having
timing issues with h264enc.

I've tried adding rawvideoparse after the input-selector, which helps the
switching but I am getting garbage video (just colored noise).



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using input-selector to change between multiple cameras for h264 encoding

Marc Leeman
In reply to this post by dlw
lib/tlvtour.c:  gst_bin_recalculate_latency(GST_BIN(self->pipeline));

On Fri, 15 Jan 2021 at 21:15, dlw <[hidden email]> wrote:

>
> I have the following pipeline with 2 cameras at different
> resolutions,framerates,formats etc.
>
> cam1(1080p, 30fps) -> videoconvert -> videorate ->capsfilter ->
> input-selector.sink_0
>
> cam2(640, 10fps) -> videoconvert -> videorate ->capsfilter ->
> input-selector.sink_1
>
> input-selector -> h264enc ->rtph264pay -> udpsink
>
> Running either input (sink_0, or sink_1) runs fine and streams correctly,
> but if I try switching while the pipeline is running the image freezes and I
> can't see a camera feed.
>
> I switch pads on the input-selector using the following:
> g_object_set(G_OBJECT(bindata->input-selector), "active-pad", new_pad,
> NULL);
>
> Is there something else I need to do to the pipeline to get the stream to
> work?  The pipeline also runs fine if I put the h264enc before the
> input-selector, but I get some image corruption during camera switches due
> to not switching on an I-frame.  I'd prefer not to use this method because I
> don't want to be running multiple hw encoders at the same time.
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



--
g. Marc
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
dlw
Reply | Threaded
Open this post in threaded view
|

Re: Using input-selector to change between multiple cameras for h264 encoding

dlw
Ok, I attempted add gst_bin_recalculate_latency() after switching the src pad
on input-selector but it did not help.

After switching I get a lot of qos messages.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using input-selector to change between multiple cameras for h264 encoding

gotsring
Since you're changing video resolutions, have you tried flushing the encoder
and sink elements, then changing state to either PAUSED or READY before
changing the stream coming from the input selector?



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel