Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:edge2:add-ons:edge2-mipi-camera

This is an old revision of the document!


Edge2 MIPI Camera Usage

Linux

Edge2 CAM3 support 4K@60fps record. If your hardware version is V13, the CAM2 also can support 4K@60fps record.

Check Hardware Version

$ cat /proc/cmdline

V13 will show like hwver=EDGE2.V13

Due to the different hardware versions, CAM2 is set to 4K@30fps by default. This is for compatibility with non-V13 hardware versions to ensure proper operation. If your device supports 4K@60fps, you can enable this mode by adding an overlay file.

$ sudo vi /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env
fdt_overlays=cam2-4lane

Upgrade System

Please follow the documentation to upgrade your system to latest version.

Video Node

You can find the video nodes from the table below.

Video Node(5.10.66) Video Node(5.10.160 and later)
CAM1 /dev/video33 /dev/video42
CAM2 /dev/video24 /dev/video33
CAM3 /dev/video42 /dev/video51

Record Video with Gstreamer

kernel 5.10.66

Record video from CAM1:

gst-launch-1.0 v4l2src device=/dev/video33 io-mode=dmabuf num-buffers=300 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video33.mp4

Record video from CAM2:

gst-launch-1.0 v4l2src device=/dev/video24 io-mode=dmabuf num-buffers=300 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video24.mp4

Record video from CAM3:

gst-launch-1.0 v4l2src device=/dev/video42 io-mode=dmabuf num-buffers=300 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video42.mp4

Other version

Record video from CAM1:

gst-launch-1.0 v4l2src device=/dev/video42 io-mode=dmabuf num-buffers=300 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=30/1 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video42.mp4

Record video from CAM2:

gst-launch-1.0 v4l2src device=/dev/video33 io-mode=dmabuf num-buffers=300 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=30/1 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video33.mp4

For 4K@60fps, framerate should be set 60/1

Record video from CAM3:

gst-launch-1.0 v4l2src device=/dev/video51 io-mode=dmabuf num-buffers=600 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=60/1 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video51.mp4

Capture Frame with V4L2 Utils

Follow the steps below to install v4l-utils:

sudo apt update
sudo apt install v4l-utils

kernel 5.10.66

Capture frame from CAM1:

v4l2-ctl -d /dev/video33 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data33.yuv --stream-count=1 --stream-poll

Capture frame from CAM2:

v4l2-ctl -d /dev/video24 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data24.yuv --stream-count=1 --stream-poll

Capture frame from CAM3:

v4l2-ctl -d /dev/video42 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data42.yuv --stream-count=1 --stream-poll

Other version

Capture frame from CAM1:

v4l2-ctl -d /dev/video42 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data42.yuv --stream-count=1 --stream-poll

Capture frame from CAM2:

v4l2-ctl -d /dev/video33 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data33.yuv --stream-count=1 --stream-poll

Capture frame from CAM3:

v4l2-ctl -d /dev/video51 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data51.yuv --stream-count=1 --stream-poll

It will capture a 3840×2160 NV12 format frame to file /tmp/dataXX.yuv.

Preview the file:

$ ffplay -f rawvideo -pixel_format nv12 -video_size 3840x2160 /tmp/dataXX.yuv

Android

WIP:

Last modified: 2024/10/29 05:43 by jacobe