How to capture a yuv frame from h.264 stream

Michael MacIntosh mmacintosh at linear-systems.com
Tue Nov 7 23:40:55 UTC 2017


Hello,

You could try changing your while loop to an if and wrapping your 
last-sample code in that, you could be getting a null item because you 
could be getting GST_ITERATOR_DONE. You could verify if sink is null as 
well.  Are you getting any error output?

As far as I know, autovideosink doesn't have an enable-last-buffer 
property (just looking at it through gst-inspect).  However 
enable-last-sample is default true for anything inheriting from base 
sink (unless I am mistaken).

Cheers,
Michael.


On 11/6/2017 4:29 PM, glenne wrote:
> Here is my current iteration code and an attempt to get an image.  My stream
> is "videotestsrc ! autovideosink enable-last-buffer=true"
>
> Unfortunately, I always get NULL for from_sample after calling g_object_get.
> Do I have an error in my
> use of item or does autovideosink not pass on the enable-last-buffer setting
> to the sink?
>
>
> static void take_pic(CustomData *data) {
>      GstIterator *sink_iterator =
> gst_bin_iterate_sinks(GST_BIN(data->pipeline));
>      GValue item = G_VALUE_INIT;
>      while (gst_iterator_next (sink_iterator, &item) == GST_ITERATOR_OK)
>      {
>      }
>
>      GstElement *sink = GST_ELEMENT(g_value_get_object (&item));
>      g_object_get (sink, "last-sample", &from_sample, (char*)NULL);
>      if (from_sample == NULL) {
>          GST_ERROR ("Error getting last sample form sink");
>          return;
>      }
>
>    GError *err = NULL;
>    GstCaps *caps = gst_caps_from_string ("image/jpeg");
>    GstSample *to_sample = gst_video_convert_sample (from_sample, caps,
> GST_CLOCK_TIME_NONE, &err);
>
>      if (to_sample == NULL) {
>          GST_ERROR ("Error converting video sample");
>          return;
>      }
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list