How to get yuv data by using v4l2src plugin?

I can get yuv data by using nvarguscamerasrc plugin,the following commands are used:
gst-launch-1.0 nvarguscamerasrc num-buffers=1 sensor-id=1 ! ‘video/x-raw(memory:NVMM), width=(int)4000, height=(int)3000, format=(string)NV12, framerate=(fraction)21/1’ ! nvvidconv ! ‘video/x-raw, format=(string)NV12’ ! filesink location = test1.yuv

But I can’t get yuv data by using v4l2src plugin,the foolowing commands are used,What’s wrong with this command?
gst-launch-1.0 v4l2src num-buffers=1 device="/dev/video1" ! ‘video/x-raw, width=(int)4000, height=(int)3000, format=(string)NV12’ ! nvvidconv ! ‘video/x-raw, format=(string)NV12’ ! filesink location = test1.yuv

Hi,
With v4l2src plugin it does not go through ISP engine. Generally it is used for USB cameras or YUV sensors.

If you need raw frame data such as BG10 from the Bayer sensor, please run v4l2-ctl command:
[32.3.1] v4l2-ctl raw streaming NOT working with OV5693 after using argus_camera app

Do you have code examples,I can get the rawdata by using v4l2-ctl command terminal,but i need use it in c/c++ program.

If you want to get bayer frames instead of yuv frames, you may use V4L2 API.
You would open the /dev/videoX node (X=0,1,…) and then use ioctl calls for exchanging from/into v4l2 structures.
I’d suggest to use strace (can be installed from apt) in order to get sys calls displayed and you may check what are the commands used for :

strace v4l2-ctl -d0 --list-formats-ext
[You can ignore the prelude trying to load dlls until:
openat(AT_FDCWD, "/dev/video0", O_RDWR) =]

# Or capturing 10 frames with my OV5693 sensor providing 1280x720@60 in BG10 format:
strace v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=BG10 --stream-mmap -d /dev/video0 --set-ctrl bypass_mode=0 --stream-count=10 --stream-to=ov5693_1280x720p60_BG10.raw

You may also check v4l2-ctl sources for further details.

1 Like

Hi,
For C sample, please refer to

/usr/src/jetson_multimedia_api/samples/v4l2cuda
1 Like