How to make v4l2src reload buffer in PAUSED state

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

How to make v4l2src reload buffer in PAUSED state

dlw
I'm a bit of a gstreamer noob, so please bear with me...

I am trying to capture single images in a pipeline with that looks like the
following:

v4l2src num-buffers=1 ! jpegenc quality=100 ! multifilesink
location="/tmp/IMG%06d.jpg"

In my code I create the pipeline elements, link them and then set the
pipeline to GST_STATE_PAUSED.

When I receive a "capture_image" command I then set the GST_STATE_PLAYING.

This works fantastic and I get an EOS and image written.  I then set the
pipeline to GST_STATE_PAUSED waiting for the next "capture_image" command.

/The problem is that now the v4l2src buffer is empty and nothing will get
written to the multifilesink on subsequent "capture_image" commands./

*Is there a way to make v4l2src send another image to its buffer and send it
down to multifilesink?*  I can only get this to work if I set the pipeline
to GST_STATE_READY, but timing is critical - it takes 600ms to capture the
images from GST_STATE_READY, but only 300ms to capture from GST_STATE_PAUSED
(multiple cameras and other processing happening that I've excluded for
simplicity).





--
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: How to make v4l2src reload buffer in PAUSED state

Nicolas Dufresne-5
Le jeudi 13 août 2020 à 14:53 -0500, dlw a écrit :

> I'm a bit of a gstreamer noob, so please bear with me...
>
> I am trying to capture single images in a pipeline with that looks like the
> following:
>
> v4l2src num-buffers=1 ! jpegenc quality=100 ! multifilesink
> location="/tmp/IMG%06d.jpg"
>
> In my code I create the pipeline elements, link them and then set the
> pipeline to GST_STATE_PAUSED.
>
> When I receive a "capture_image" command I then set the GST_STATE_PLAYING.
>
> This works fantastic and I get an EOS and image written.  I then set the
> pipeline to GST_STATE_PAUSED waiting for the next "capture_image" command.
>
> /The problem is that now the v4l2src buffer is empty and nothing will get
> written to the multifilesink on subsequent "capture_image" commands./
>
> *Is there a way to make v4l2src send another image to its buffer and send it
> down to multifilesink?*  I can only get this to work if I set the pipeline
> to GST_STATE_READY, but timing is critical - it takes 600ms to capture the
> images from GST_STATE_READY, but only 300ms to capture from GST_STATE_PAUSED
> (multiple cameras and other processing happening that I've excluded for
> simplicity).

To follow your design, you'd simply need to send two events into the
pipeline, flush-start followed by flush-stop event. You'll have to bump
multifilesink index each time othewise the index is also reset by the
flush (and file will

Now, why this is not idea is because while streaming, cameras run
algorithm to improve image quality. Meaning that the very first image
is not always in the best possible shape of what you camera can do.

What applications open do, is build a pipeline with a "view finder" / a
live preview of the image. And then can capture images on demand using
"last-sample" property and gst_video_convert_sample() API. Or, for more
advance usage, mais use a tee and other sinks, notably appsink.

Nicolas

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

Re: How to make v4l2src reload buffer in PAUSED state

dlw
Thanks Nicolas.

I was trying to send the flush_start and flush_stop using the following but wasn’t having luck getting new images from v4l2src (num-buffers=1)

gst_element_send_event(GST_ELEMENT(pipeline), gst_new_event_flush_start());
gst_element_send_event(GST_ELEMENT(pipeline), gst_new_event_flush_stop(false));

Is this correct?  Am I supposed to send this event to the pipeline object or the v4l2src object?



To follow your design, you'd simply need to send two events into the
pipeline, flush-start followed by flush-stop event. You'll have to bump
multifilesink index each time othewise the index is also reset by the
flush (and file will

Now, why this is not idea is because while streaming, cameras run
algorithm to improve image quality. Meaning that the very first image
is not always in the best possible shape of what you camera can do.

What applications open do, is build a pipeline with a "view finder" / a
live preview of the image. And then can capture images on demand using
"last-sample" property and gst_video_convert_sample() API. Or, for more
advance usage, mais use a tee and other sinks, notably appsink.

Nicolas



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

Re: How to make v4l2src reload buffer in PAUSED state

Nicolas Dufresne-5
Le vendredi 14 août 2020 à 18:14 +0000, David Walter a écrit :
> Thanks Nicolas.
>
> I was trying to send the flush_start and flush_stop using the following but wasn’t having luck getting new images from v4l2src (num-buffers=1)
>
> gst_element_send_event(GST_ELEMENT(pipeline), gst_new_event_flush_start());
> gst_element_send_event(GST_ELEMENT(pipeline), gst_new_event_flush_stop(false));
>
> Is this correct?  Am I supposed to send this event to the pipeline object or the v4l2src object?

Perhaps the num-buffers counter is not reset on flush-start/stop, you
would have to check the code in GstBaseSrc.

>
>
> > To follow your design, you'd simply need to send two events into the
> > pipeline, flush-start followed by flush-stop event. You'll have to bump
> > multifilesink index each time othewise the index is also reset by the
> > flush (and file will
> >
> > Now, why this is not idea is because while streaming, cameras run
> > algorithm to improve image quality. Meaning that the very first image
> > is not always in the best possible shape of what you camera can do.
> >
> > What applications open do, is build a pipeline with a "view finder" / a
> > live preview of the image. And then can capture images on demand using
> > "last-sample" property and gst_video_convert_sample() API. Or, for more
> > advance usage, mais use a tee and other sinks, notably appsink.
> >
> > Nicolas
> >
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel