I am working on an openCV project, I have a stable running variant that is taking input from an HDMI capture card and using FFmpeg to output to a v4L2 loopback device (/dev/video0) my openCV project takes its input from /dev/video0.
The issue comes when I try to use an rtsp feed, the following command works to send the feed to my loopback device:
ffmpeg -rtsp_transport tcp -i rtsp://@192.168.1.27:552//stream1 -acodec rawvideo -vcodec rawvideo -f v4l2 /dev/video0
And I am able to view that feed with VLC (on /dev/video0) no problem, however when I feed it to my openCV app, I get the following error:
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
When I run v4l2-ctl -d /dev/video0 --all
on both working and non working variants this is what I get:
Working output
Format Video Output:
Width/Height : 1920/1080
Pixel Format : 'UYVY'
Field : None
Bytes per Line : 3840
Size Image : 4147200
Colorspace : sRGB
Transfer Function : Default
YCbCr Encoding : Default
Quantization : Default
Flags :
Nonfunctional output
Format Video Output:
Width/Height : 1280/720
Pixel Format : 'YU12'
Field : None
Bytes per Line : 1280
Size Image : 1382400
Colorspace : sRGB
Transfer Function : Default
YCbCr Encoding : Default
Quantization : Default
Flags :
So I am concluding that the pixel format 'YU12' is not compatible with openCV while format 'UYVY' is. If it's possible, how do I set the output of FFmpeg to be in pixel format UYVY when the input is YU12?