v4l2h264enc Invalid color format in RGBA input video

vasilimerk VasiliMerk at proton.me
Mon Dec 12 09:00:33 UTC 2022


Trying to pipe video feed from v4l2src to v4l2covert and then v4l2h264enc. 
Source is an analog camera producing 50fps UYVY video. Need to convert color 
space to RGBA to get a fork of it using tee and feed it into qmlglsink somewhere 
else. Using the following pipeline, I'm getting encoded video with swapped 
colors (R in inplace of B and vice-versa):

gst-launch-1.0 v4l2src norm=PAL do-timestamp=true ! \
video/x-raw,format=UYVY,width=720,height=576 ! \
videocrop left=8 right=8 ! v4l2convert ! video/x-raw,format=RGBA ! \
v4l2h264enc ! video/x-h264,level="(string)3.1" ! filesink location="output.mp4"

So then I tried to manipulate color format info using capssetter and change 
RGBA to BGRA as encoder supports both formats and probably this would fix it. 
But after inserting the capssetter into the pipeline, it won't start and it'll 
return errors.

The pipeline:

gst-launch-1.0 v4l2src norm=PAL ! \
video/x-raw,format=UYVY,width=720,height=576 ! \
videocrop left=8 right=8 ! v4l2convert ! \
video/x-raw,format=RGBA,width=704,height=576,framerate=25/1, \
interlace-mode=progressive ! \
capssetter join=true replace=false \
caps="video/x-raw,format=BGRA,framerate=50/1" ! \
v4l2h264enc ! video/x-h264,level="(string)3.1" ! filesink location="output.mp4"

errors in gst-launch output:

GST_CAPS gstpad.c:3240:gst_pad_query_accept_caps_default:<v4l2h264enc0:sink> 
caps: video/x-raw, framerate=(fraction)50/1, interlace-mode=(string)progressive, 
format=(string)BGRA, width=(int)704, height=(int)576 were not compatible with: 
EMPTY
basetransform gstbasetransform.c:1371:gst_base_transform_setcaps:<capssetter0> 
transform could not transform video/x-raw, framerate=(fraction)25/1, 
interlace-mode=(string)progressive, format=(string)RGBA, width=(int)704, 
height=(int)576 in anything we support


Machine is a raspberrypi 4 device. Asking the same question in their forum, 
they said they "did check the byte ordering for RGBA and confirmed that it was 
correct, which means it is GStreamer that has the mismatch. You can use 
capssetter to correct the mismatch.", but I did not get answers about the output 
error after inserting capssetter into the pipeline.


More information about the gstreamer-embedded mailing list