# gdkpixbufsink

This sink element takes RGB or RGBA images as input and wraps them into GdkPixbuf objects, for easy saving to file via the GdkPixbuf library API or displaying in Gtk+ applications (e.g. using the GtkImage widget).

There are two ways to use this element and obtain the GdkPixbuf objects created:

- Watching for element messages named `preroll-pixbuf` or `pixbuf` on the bus, which will be posted whenever an image would usually be rendered. See below for more details on these messages and how to extract the pixbuf object contained in them.

- Retrieving the current pixbuf via the last-pixbuf property when needed. This is the easiest way to get at pixbufs for snapshotting purposes - just wait until the pipeline is prerolled (ASYNC_DONE message on the bus), then read the property. If you use this method, you may want to disable message posting by setting the post-messages property to FALSE. This avoids unnecessary memory overhead.

The primary purpose of this element is to abstract away the GstBuffer to GdkPixbuf conversion. Other than that it's very similar to the fakesink element.

This element is meant for easy no-hassle video snapshotting. It is not suitable for video playback or video display at high framerates. Use ximagesink, xvimagesink or some other suitable video sink in connection with the GstVideoOverlay interface instead if you want to do video playback.

## Message details

As mentioned above, this element will by default post element messages containing structures named `preroll-pixbuf` `or`pixbuf` on the bus (this can be disabled by setting the post-messages property to FALSE though). The element message structure has the following fields:

- `pixbuf`: the GdkPixbuf object
- `pixel-aspect-ratio`: the pixel aspect ratio (PAR) of the input image (this field contains a value of type GST_TYPE_FRACTION); the PAR is usually 1:1 for images, but is often something non-1:1 in the case of video input. In this case the image may be distorted and you may need to rescale it accordingly before saving it to file or displaying it. This can easily be done using gdk_pixbuf_scale (the reason this is not done automatically is that the application will often scale the image anyway according to the size of the output window, in which case it is much more efficient to only scale once rather than twice). You can put a videoscale element and a capsfilter element with `video/x-raw-rgb,pixel-aspect-ratio=(fraction)1/1` caps in front of this element to make sure the pixbufs always have a 1:1 PAR.

## Example pipeline

     gst-launch-1.0 -m -v videotestsrc num-buffers=1 ! gdkpixbufsink

Process one single test image as pixbuf (note that the output you see will be slightly misleading. The message structure does contain a valid pixbuf object even if the structure string says '(NULL)').

## Hierarchy

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstElement
                    ╰──GstBaseSink
                        ╰──GstVideoSink
                            ╰──gdkpixbufsink

## Factory details

Authors: – Tim-Philipp Müller

Classification: – `Sink/Video`

Rank – none

Plugin – gdkpixbuf

Package – GStreamer Good Plug-ins

## Pad Templates

### `sink`

    video/x-raw:
             format: RGB
              width: [ 1, 2147483647 ]
             height: [ 1, 2147483647 ]
          framerate: [ 0/1, 2147483647/1 ]
    video/x-raw:
             format: RGBA
              width: [ 1, 2147483647 ]
             height: [ 1, 2147483647 ]
          framerate: [ 0/1, 2147483647/1 ]

Presence – always

Direction – sink

Object type – GstPad

## Properties

### last-pixbuf

    “last-pixbuf” GdkPixbuf*

Last GdkPixbuf object rendered

Flags : Read

### post-messages

    “post-messages” gboolean

Whether to post messages containing pixbufs on the bus

Flags : Read / Write

Default value : true

The results of the search are