Monday, June 2, 2014

Video Colorspace conversion with ffmpegcolorspace and similar Gstreamer Plugin

There are cases when we need colorspace conversion when decoding video with gst-launch tool of Gstreamer. We can use ffmpegcolorspace or videoconvert gstreamer plugin for the same.


$ gst-launch-0.10 -v filesrc location=big_buck_bunny.mp4 ! qtdemux ! vmetadec ! 'video/x-raw-yuv,format=(fourcc)UYVY' ! ffmpegcolorspace ! 'video/x-raw-yuv,format=(fourcc)I420' ! autovideosink


Above example gives you idea about how to tell ffmpegcolorspace plugin about from which format to convert and in what format to give output.

'video/x-raw-yuv,format=(fourcc)UYVY' ! ffmpegcolorspace ! 'video/x-raw-yuv,format=(fourcc)I420'


So just remember above pipeline to convert from UYVY colorspace to I420 colorspace. You can change formats in above pipeline as per your need.

In newer version of gstreamer, ffmpegcolorspace is replaced with videoconvert plugin. So above pipeline for newer version of gstreamer can be represented as below.

 'video/x-raw-yuv,format=(fourcc)UYVY' ! videoconvert ! 'video/x-raw-yuv,format=(fourcc)I420'

Hope that's clear. Let me know should you have any further questions !