Search code examples
gstreamercolor-channel

GStreamer - swap color channels of RGB-video


I am new to GStreamer and I try to swap the color channels of a RGB-video. (e.g. red to blue). How can I do this with gst-launch?

I go trough this list but I am unable to find an element to do it: http://gstreamer.freedesktop.org/documentation/plugins.html


Solution

  • You can actually trick GStreamer by replacing the caps:

    gst-launch-1.0 -v videotestsrc ! video/x-raw, format=RGBx ! capssetter replace=true caps="video/x-raw, format=(string)BGRx, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive" ! videoconvert ! ximagesink

    Please note that:

    "width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive"

    are the default settings for videotestsrc. If you, for example, want another resolution, you need to declare it twice:

    gst-launch-1.0 -v videotestsrc ! video/x-raw, format=RGBx, width=640, height=480 ! capssetter replace=true caps="video/x-raw, format=(string)BGRx, width=(int)640, height=(int)480, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive" ! videoconvert ! ximagesink

    But of course having a dedicated element is the better solution in order to support proper dynamic caps negotiation.