7

I have a HDMI capture card and I'm using raspbian.

I want to get one single frame with v4l2-ctl command, then convert it to something common:

Get a frame:

# v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1

Convert it:

# convert -size 1280x720 -depth 16 uyvy:frame.raw frame.png

1280x720 is the resolution what v4l2-ctl --query-dv-timings reports as active.

The problem is that I can not get a clean capture, it always has a green ending at the bottom (sometimes smaller, sometimes larger!):

enter image description here

How can I get the whole picture captured with v4l2-ctl? Maybe the conversion is wrong (I get that from http://trac.gateworks.com/wiki/linux/v4l2).

Thanks!

2 Answers 2

1

Try steaming with jpg, below code i have tried .

v4l2-ctl --device /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=MJPEG --stream-mmap --stream-to=frame.jpg --stream-count=1
2
  • The pixelformat 'MJPEG' is invalid
    – juanmf
    Commented Oct 14, 2023 at 21:16
  • If you check v4l2-ctl --device /dev/video0 --list-formats-ext for formats (see also other answer) the correct format to use is MJPG.
    – zany
    Commented Feb 8 at 20:07
1

Raw image data is rarely standardized. Are you certain that uyvy with 16 bit depth is the correct mapping? Solid green at the bottom half of the image certainly appears to be misinterpretation of raw data, in particular planar data. If your goal is to just get a standard image out of the camera, try using one of the camera's natively supported formats:

$ v4l2-ctl --device /dev/video0 --list-formats-ext
...
    [0]: 'MJPG' (Motion-JPEG, compressed)
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 3840x2160
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.000 fps)
...
    [1]: 'YUYV' (YUYV 4:2:2)
        Size: Discrete 1920x1080
            Interval: Discrete 0.500s (2.000 fps)
        Size: Discrete 3840x2160
            Interval: Discrete 1.000s (1.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
            Interval: Discrete 0.500s (2.000 fps)
...

Then:

$ v4l2-ctl \
  --device /dev/video0 \
  --set-fmt-video=width=3840,height=2160,pixelformat=MJPG \
  --stream-mmap --stream-to=frame.jpg --stream-count=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.