BBAI64 IMX219 save video to file

I’m trying to save an image from an imx219 camera to a mkv or avi file, but it cannot be played by any video player.

I use Images

  1. https://www.beagleboard.org/distros/bbai64-11-8-2023-10-07-10gb-emmc-ti-edgeai-xfce-flasher

  2. https://rcn-ee.net/rootfs/debian-arm64-11-bullseye-xfce-edgeai-v5.10-ti/2024-02-15/bbai64-emmc-flasher-debian-11.9-xfce-edgeai-arm64-2024-02-15-10gb.img.xz

bin files

https://github.com/Hypnotriod/bbai64/raw/master/imaging.zip

All that comes out is this:

saving photo

Спойлер

media-ctl -d 0 --set-v4l2 ‘“imx219 6-0010”:0[fmt:SRGGB8_1X8/640x480]’

sudo gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=10 ! video/x-bayer, width=640, height=480, format=rggb ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss_640x480.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_640x480.bin format-msb=7 ! timeoverlay ! jpegenc ! multifilesink location=“/media/img_%06d.jpg”

UDP broadcast

Спойлер

media-ctl -d 0 --set-v4l2 ‘“imx219 6-0010”:0[fmt:SRGGB8_1X8/640x480]’

sudo gst-launch-1.0 v4l2src device=/dev/video2 ! video/x-bayer, width=640, height=480, format=rggb, framesize=30/1 ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss_640x480.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_640x480.bin format-msb=7 ! video/x-raw, format=NV12 ! v4l2h264enc ! rtph264pay mtu=60000 config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=1234 -e

play
gst-launch-1.0 udpsrc port=1234 ! application/x-rtp ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink

saving RAW image to file and playing back YUView

Спойлер

media-ctl -d 0 --set-v4l2 ‘“imx219 6-0010”:0[fmt:SRGGB8_1X8/640x480]’

sudo gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=150 ! queue leaky=2 ! video/x-bayer, width=640, height=480, format=rggb, framerate=30/1 ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss_640x480.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_640x480.bin format-msb=7 ! video/x-raw, format=NV12 ! tiovxcolorconvert ! video/x-raw, format=NV12, width=640, height=480 ! timeoverlay ! rawvideoparse ! filesink location=/media/output.yuv

but saved video files MKV or AVI are not played

Спойлер

media-ctl -d 0 --set-v4l2 ‘“imx219 6-0010”:0[fmt:SRGGB8_1X8/640x480]’

sudo gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=150 io-mode=5 ! video/x-bayer, width=640, height=480, format=rggb, framesize=30/1 ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss_640x480.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_640x480.bin format-msb=7 ! video/x-raw, format=NV12 ! videoconvert ! v4l2h264enc ! h264parse ! matroskamux ! filesink location=/media/tests.mkv

I have already tried many combinations without success. Can anyone tell me what I’m doing wrong?

Maybe try to compose this pipeline on your pc with videotestsrc as source? At least you will know that solution is working or not.

This works on PC
sudo gst-launch-1.0 -e videotestsrc ! video/x-raw, width=640, height=480, framesize=30/1 ! videoconvert ! x264enc ! h264parse ! matroskamux ! filesink location=/media/tests.mkv

But this doesn’t work on BBAI64
sudo gst-launch-1.0 -e videotestsrc ! video/x-raw, width=640, height=480, framesize=30/1 ! videoconvert ! v4l2h264enc ! h264parse ! matroskamux ! filesink location=/media/tests.mkv

Maybe try different solution with mp4 from this thread for example:
Beaglebone ai-64 edge_ai_apps [ERROR] Could not get allowed GstCaps of device - General Discussion - BeagleBoard

Thanks for the help! But I never got the pipeline to work. Apparently v4l2h264enc it doesn’t work properly…

this pipline last i tryed
sudo gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=150 ! video/x-bayer, width=640, height=480, format=rggb ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss_640x480.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_640x480.bin format-msb=7 ! video/x-raw, format=NV12 ! autovideoconvert ! v4l2h264enc extra-controls=controls,h264_profile=3,video_bitrate=200000 ! h264parse ! video/x-h264,stream-format=“avc”,alignment=“au” ! matroskamux ! filesink location=/media/tests.mkv

It seems v4l2h264enc is working, I was able to record from the camera to the .h264 file. But it doesn’t work with wrappers avi mkv or mp4…

Спойлер

sudo gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=150 ! video/x-bayer, width=640, height=480, format=rggb, framerate=30/1 ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss_640x480.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_640x480.bin format-msb=7 ! video/x-raw, format=NV12 ! v4l2h264enc ! filesink location=/media/test.h264

v4l2h264enc not set and unsuportet this parametres extra-controls=“encode,video_bitrate=368640,video_bitrate_mode=1,h264_level=10,h264_profile=0;”

v4l2-ctl -L
gop_size 0x009909cb (int) : min=1 max=7200 step=1 default=1800 value=1800
video_bitrate 0x009909cf (int) : min=50000 max=100000000 step=1 default=500000 value=0
h264_i_period 0x00990a66 (int) : min=1 max=600 step=1 default=30 value=0