How and why v4l2src able to take YV12 format?

Nicolas Dufresne nicolas at ndufresne.ca
Thu Nov 14 19:42:42 UTC 2019


Le jeudi 14 novembre 2019 à 12:12 -0600, jeyp4 a écrit :
> My USB camera has 2 pixel formats, MJPG & YUYV
> 
> jai at jai:~$ v4l2-ctl -d /dev/video0 --list-formats-ext
> ioctl: VIDIOC_ENUM_FMT
> 	Index       : 0
> 	Type        : Video Capture
> 	Pixel Format: 'MJPG' (compressed)
> 	Name        : Motion-JPEG
> 		Size: Discrete 1920x1080
> 			Interval: Discrete 0.017s (60.000 fps)
> 		Size: Discrete 1280x720
> 			Interval: Discrete 0.017s (60.000 fps)
> 		Size: Discrete 640x480
> 			Interval: Discrete 0.017s (60.000 fps)
> 
> 	Index       : 1
> 	Type        : Video Capture
> 	Pixel Format: 'YUYV'
> 	Name        : YUYV 4:2:2
> 		Size: Discrete 1920x1080
> 			Interval: Discrete 0.017s (60.000 fps)
> 		Size: Discrete 1280x720
> 			Interval: Discrete 0.017s (60.000 fps)
> 		Size: Discrete 640x480
> 			Interval: Discrete 0.017s (60.000 fps)
> 
> 
> But v4l2src is able to except YUV2, YV12 as well as I420. How?

You have libv4l2 enabled, which integrate a software color converter.
The library has many known issues, and no maintainer. So we have
dropped it in newer GStreamer version. You can regain the same by using
videoconvert, or jpegdec ! videoconvert, with the difference that
GStreamer will be aware of the costy operation.

Note that to not let down valid usage of that lib, we have introduced
the environment variable GST_V4L2_USE_LIBV4L2=1, which enabled the lib
at run-time. We have made good effort to workaround most of the known
libv4l2 issues, but it is advised to avoid io-mode=dmabuf (default) and
force io-mode=mmap.

> gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw,
> format=YV12,width=1280, height=720, framerate=60/1' ! fpsdisplaysink
> video-sink=fakesink text-overlay=false -v
> 
> Above pipeline works fine.
> 
> Actually it's a positive aspect for me. I am worried because if I connect
> camera to jetson, v4l2src can only take mjpg and YUV2. I want jetson also to
> take YV12 and I420.
> 
> Intel computer's GStreamer 1.8.3.
> Jetson's GStreamer 1.14.5

New NVidia SDK depends heavily on libv4l2, so they have enabled it by
default. So you might not have to care too much there. That being said,
if you have a battery oriented device, I would recommend to try and use
the HW accelerated color converter on that target.

Nicolas



More information about the gstreamer-devel mailing list