[gst-devel] Newbie question - how to get video frames from pipeline

Štěpán stepan1117 at atlas.cz
Tue Mar 31 20:03:50 CEST 2009


Hi,
    thanks for your example, it helped me a lot. In fact, it nearly
works already for me (I'll post the sourcecode when I am finished), but
I have one slight problem - I cannot resize the video during playback.
The important parts of code I am using are:

#define CAPS
"video/x-raw-rgb,pixel-aspect-ratio=1/1,bpp=(int)32,depth=(int)32,endianness=(int)4321,red_mask=(int)65280,
green_mask=(int)16711680, blue_mask=(int)-16777216, alpha_mask=(int)255"

...
void main(){
gchar * descr = g_strdup_printf ("uridecodebin uri=file://%s !
ffmpegcolorspace ! videoscale ! capsfilter name=flt !"
          " appsink name=sink caps=\"" CAPS "\"", filename);
      pipeline = gst_parse_launch (descr, &errorMessage);

      if (errorMessage != NULL) {

        g_print ("could not construct pipeline: %s", errorMessage->message);
        g_error_free (errorMessage);
        exit (-1);
      }

      /* get sink */
      sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");

      g_object_set (G_OBJECT (sink), "emit-signals", TRUE, "sync", TRUE,
NULL);
      g_signal_connect (sink, "new-buffer",
           G_CALLBACK (on_new_buffer_from_source), 0);

      GMainLoop * loop = g_main_loop_new (NULL, FALSE);
      bus = gst_element_get_bus (pipeline);
      gst_bus_add_watch (bus, (GstBusFunc) on_sink_message, loop);
      gst_object_unref (bus);
}

...

void on_new_buffer_from_source (GstElement * elt, gpointer data)
{
  g_print("Buffer arrived\n");
  GstBuffer *buffer;

  /* get the buffer from appsink */
  buffer = gst_app_sink_pull_buffer (GST_APP_SINK (elt));


...

void changeResolution(int w, int h){

    if (desiredW != w || desiredH != h){

        std::cout << "Changing resolution from ["<< desiredW << "x" <<
desiredH << "] to [" << w << "x" << h << "]" << std::endl;

        desiredW = w;
        desiredH = h;
        needResize = true;
        GstElement * flt  = gst_bin_get_by_name (GST_BIN (pipeline), "flt");
        g_object_set (G_OBJECT (flt), "caps",
                  gst_caps_new_simple ("video/x-raw-rgb",
                             "width", G_TYPE_INT, w,
                             "height", G_TYPE_INT, h,
                             NULL), NULL);
        gst_object_unref(flt);

    }
}

Everything works fine until the changeResolution() is called, then it
stops giving me new buffers in on_new_buffer_from_source.
Thanks,
    Stepan



Tim-Philipp Müller napsal(a):
>
>
> Here's a simple example demonstrating how to extract raw RGB video
> frames with appsink:
>
> http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/examples/snapshot/snapshot.c
>
> Hope this helps.
>
> Cheers
>  -Tim
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>   




More information about the gstreamer-devel mailing list