GStreamer - 交换 RGB 视频的颜色通道

GStreamer - swap color channels of RGB-video

我是 GStreamer 的新手,我尝试交换 RGB 视频的颜色通道。 (例如红色到蓝色)。我如何使用 gst-launch 执行此操作?

我浏览了这个列表,但我无法找到一个元素来做到这一点:http://gstreamer.freedesktop.org/documentation/plugins.html

我现在写了我自己的元素。我使用 "Colorflip" 作为我的基本元素,将名称更改为 "ChannelFlip"(您必须将所有方法从 gst_video_flip_bla 重命名为 gst_channel_flip_bla 并重命名结构)。 然后我可以用以下方式注册我的元素:

gst_element_register(NULL, "channelflip", GST_RANK_NONE, GST_TYPE_CHANNEL_FLIP);

然后我将我的枚举添加到 GstChannelFlipMethod,将我的属性添加到 _GstChannelFlip。将大写更改为 "RGB" 并将我的代码添加到 gst_channel_flip_packed_simple 并在 gst_channel_flip_transform_frame 而不是 videoflip->process (videoflip, out_frame, in_frame); 中调用它:

GST_OBJECT_LOCK (videoflip);
    //videoflip->process (videoflip, out_frame, in_frame);
    gst_channel_flip_packed_simple(videoflip, out_frame, in_frame);
GST_OBJECT_UNLOCK (videoflip);

您实际上可以通过更换大写字母来欺骗 GStreamer:

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

请注意:

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

videotestsrc 的默认设置。例如,如果您想要另一个分辨率,则需要声明两次:

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

当然,为了支持适当的动态上限协商,拥有专用元素是更好的解决方案。