Gstreamer videoconvert not compatible with hardware encoding

Hello,

I’m using gstreamer on a Radxa Cubie A7S with t4(trixie) to grab images from an USB camera to a h264/mp4 file and now I’m trying to use the A7S hardware encoding capabilities.

I’ve a problem when the video source is different than YV12 or NV12: it seems the omxh264videoenc cannot accept buffers created by videoconvert plugin.
To summarize my problem, I reproduced it using just videotestsrc plugin.

If I configure the source to produce directly YV12 format, everything is fine:
sudo gst-launch-1.0 videotestsrc is-live=true num-buffers=600 ! video/x-raw,width=1920,height=1080,framerate=30/1,format=YV12 ! omxh264videoenc ! fakesink
OK!!!

If I force the source to produce YUY2 (like my camera) and then I use videoconvert to convert it to YV12, the problem starts:
sudo gst-launch-1.0 videotestsrc is-live=true num-buffers=600 ! video/x-raw,width=1920,height=1080,framerate=30/1,format=YUY2 ! videoconvert ! video/x-raw,format=YV12 ! omxh264videoenc ! fakesink
FAIL!!!

The pipeline stops with a “failed to configure the buffer pool” error on the videoconvert plugin.

If I use the x264enc software encoder instead of omxh2644videoenc, also the second pipeline works perfectly, so I suppose the pipeline structure is correct.

I tried with all the omxh264videoenc accepted formats (NV12, I420… ), but it seems the omxh264videoenc does not accept any kind of buffer created by videoconvert plugin, same behaviour using videoscale plugin.
I tried also some queue plugin in the middle, different colorimetries and so on, but nothing seems to solve this issue.

Does anyone faced the same problem?

Any idea?

I’ve been playing with gstreamer this weekend and with latest CLI image your pipe example worked fine:

gst-launch-1.0 videotestsrc is-live=true num-buffers=600 ! video/x-raw,width=1920,height=1080,framerate=30/1,format=YUY2 ! videoconvert ! video/x-raw,format=YV12 ! omxh264videoenc ! filesink location=test.mp4

Problem is with NV12, it can encode but i think omxh264videoenc expects YV12 format.

And videoconvert most likely doing a software conversion.

Note:

I attached a USB webcam, v4l2src failed with:

0:00:00.146889825   697 0xaaaaf2db2e00 DEBUG                   v4l2 v4l2_calls.c:529:gst_v4l2_open:v4l2src0:src Trying to open device /dev/video2
0:00:00.146907535   697 0xaaaaf2db2e00 INFO                    v4l2 v4l2_calls.c:540:gst_v4l2_open:v4l2src0:src enable aw isp!
0:00:00.146918619   697 0xaaaaf2db2e00 INFO                    v4l2 v4l2_calls.c:560:gst_v4l2_open:v4l2src0:src Get device id = 2
0:00:00.146997835   697 0xaaaaf2db2e00 INFO                    v4l2 v4l2_calls.c:577:gst_v4l2_open:v4l2src0:src —VIDIOC_SET_DMA_MERGE[1] start—

0:00:00.147009878   697 0xaaaaf2db2e00 ERROR                   v4l2 v4l2_calls.c:579:gst_v4l2_open:v4l2src0:src VIDIOC_SET_DMA_MERGE error!
  • maybe not enough cma reserved memory!

Update 2:

yeah, that was cma issue, but now libisp crashed with uvcvideo driver, so csi camera depends on libisp to work properly and libisp crash with uvcdriver. We can only hope radxa engage with allwinner to fix this or get some workaround.

0:00:00.285649011   572 0xaaaad428b800 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:1534:gst_v4l2_buffer_pool_release_buffer:v4l2src0:pool0:src release buffer 0xaaaad42c6a20
[ISP]>>>>>>>>>>>>>>>>>>>> ISP VERSION INFO <<<<<<<<<<<<<<<<<<<
IPCORE: ISP602
branch: libisp-dev
commit: 665dc2e9613716c25abb6b64af145a73b989271e
date  : Wed Dec 18 15:26:13 2024 +0800
author: [email protected]

[ISP]video device name is vin_video2
[ISP_ERR]isp_get_isp_id, line: 217,can not get entity by name vin_video2
[AWIspApi]: F:awIspGetIspId, L:104, video2 → isp-2
Caught SIGSEGV
exec gdb failed: No such file or directory
Spinning.  Please run ‘gdb gst-launch-1.0 572’ to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.
^Chandling interrupt.
Interrupt: Stopping pipeline …
Execution ended after 0:00:11.663424634

I don’t think the frame from uvcdriver should pass through libisp:

[ISP]>>>>>>>>>>>>>>>>>>>> ISP VERSION INFO <<<<<<<<<<<<<<<<<<<
IPCORE: ISP602
branch: libisp-dev
commit: 665dc2e9613716c25abb6b64af145a73b989271e
date  : Wed Dec 18 15:26:13 2024 +0800
author: [email protected]

[ISP]video device name is vin_video2
[ISP_ERR]isp_get_isp_id, line: 217,can not get entity by name vin_video2
[AWIspApi]: F:awIspGetIspId, L:104, video2 → isp-2

Thread 4 “v4l2src0:src” received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xfffff4c101b0 (LWP 832)]
0x0000fffff624f0c4 in isp_set_stitch_mode ()
from /usr/lib/aarch64-linux-gnu/libisp.so
(gdb) st
Ambiguous command “st”: stack, start, starti, status, step, stepi, stepping, stop, strace.
(gdb) bt
#0  0x0000fffff624f0c4 in isp_set_stitch_mode ()
at /usr/lib/aarch64-linux-gnu/libisp.so
#1  0x0000fffff67160b8 in  () at /usr/lib/aarch64-linux-gnu/libAWIspApi.so
#2  0x0000fffff68dfe00 in  ()
at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
#3  0x0000fffff68e0644 in  ()
at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
#4  0x0000fffff7ea1e90 in gst_buffer_pool_set_active ()
at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#5  0x0000fffff68e55f4 in  ()
at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
#6  0x0000fffff6875734 in  () at /usr/lib/aarch64-linux-gnu/libgstbase-1.0.so.0
#7  0x0000fffff6879098 in  () at /usr/lib/aarch64-linux-gnu/libgstbase-1.0.so.0
#8  0x0000fffff7f1a11c in  ()
at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#9  0x0000fffff7d8b438 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#10 0x0000fffff7d8a964 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#11 0x0000fffff7c76648 in start_thread (arg=0xfffff4c0fab0)
at pthread_create.c:477
#12 0x0000fffff7bccd5c in thread_start ()
at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78


My last attempt:

gstreamer requires setting en-awisp=0 to avoid passing the frame to libawisp (i have imx-214 and usb camera attached), but then I run into a wall: there is no way to force v4l2src to use a format other than NV12 (maybe is the proprietary nv12 format?), and I get the following error:

0:00:03.206974784  2374 0xaaaac48054d0 DEBUG                   v4l2 v4l2_calls.c:529:gst_v4l2_open:v4l2src0:src Trying to open device /dev/video0
0:00:03.207007368  2374 0xaaaac48054d0 INFO                    v4l2 v4l2_calls.c:560:gst_v4l2_open:v4l2src0:src Get device id = 0
0:00:03.207151829  2374 0xaaaac48054d0 INFO                    v4l2 v4l2_calls.c:584:gst_v4l2_open:v4l2src0:src —VIDIOC_S_INPUT[0] start—

0:00:03.207190580  2374 0xaaaac48054d0 INFO                    v4l2 v4l2_calls.c:598:gst_v4l2_open:v4l2src0:src —VIDIOC_S_PARM[0] start—

0:00:03.207221705  2374 0xaaaac48054d0 ERROR                   v4l2 v4l2_calls.c:600:gst_v4l2_open:v4l2src0:src VIDIOC_S_PARM error!

I tried to update to latest radxa-allwinner deb packages but run into dependencies hell.

As far as I know in the radxa systems v4L2src can be used with radxa cameras only. I use libcamerasrc (sudo apt gstreamer1.0-libcamera) but unfortunately is not available on r6 image. It can be installeded on t4 image that is based on trixie. It is still a test version and it has some problems as the one I described.