ROCK5 vpu encode issues

I’m trying to encode video stream from hdmirx using rkmpp.
After I installed latest mpp and gstreamer-rockchip, mpph265enc can be find in sudo gst-inspect-1.0 (root privilege is required).
But using the command below get an error output.

$ sudo gst-launch-1.0 v4l2src device=/dev/video0 ! queue ! video/x-raw,format=BGR,height=1080,width=1920  ! mpph264enc ! filesink location=test.mp4
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
rga_api version 1.7.3_[6]
 RgaBlit(1439) RGA_BLIT fail: Device or resource busy
 RgaBlit(1440) RGA_BLIT fail: Device or resource busy
fd-vir-phy-hnd-format[22, (nil), (nil), 0, 0]
rect[0, 0, 1920, 1080, 5760, 1080, 1792, 0]
f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
fd-vir-phy-hnd-format[27, (nil), (nil), 0, 0]
rect[0, 0, 1920, 1080, 1920, 1088, 2560, 0]
f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
This output the user patamaters when rga call blit fail
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:01.188796028
Setting pipeline to NULL ...
ERROR: from element /GstPipeline:pipeline0/GstQueue:queue0: Internal data stream error.
Additional debug info:
../plugins/elements/gstqueue.c(990): gst_queue_handle_sink_event (): /GstPipeline:pipeline0/GstQueue:queue0:
streaming stopped, reason not-negotiated (-4)
Freeing pipeline ...

And the dmesg shows

[ 2132.852028] fdee0000.hdmirx-controller: stream stopping finished
[ 2139.872282] rga_job: rga_job_wait timeout
[ 2139.872299] rga3_reg: soft reset sys_ctrl = 18, ro_rest = 1
[ 2139.892309] rga3_reg: soft reset sys_ctrl = 18, ro_rest = 1
[ 2139.892314] rga3_reg: soft after reset sys_ctrl = 0, ro_rest = 0
[ 2139.892327] rga_job: rga request commit failed!
[ 2139.892333] rga: rga_request_commit failed
[ 2139.910241] fdee0000.hdmirx-controller: stream start stopping
[ 2139.910986] fdee0000.hdmirx-controller: stream stopping finished

Is it because the wrong command or the vpu drivers problems? Has anyone succeed in running hardware encoding video?

1 Like

@Yadomin
I think that problem will be in mpph264enc
as it don’t support
video/x-raw,format=BGR,height=1080,width=1920
for sure
h264 dont support RGB
and also width and height must be divisible by 16 I think
so height must be 1088
and color format must be something that mpph264enc can support

so I would start with separating that into two pipelines
gst-launch-1.0 v4l2src device=/dev/video0 ! queue ! video/x-raw,format=NV12,height=1088,width=1920 ! fakesink

1 Like

I don’t know what device mpph264enc actually use
you can change rights for that device so you don’t need to run gst with sudo
This is something I used for arm mali drivers

sudo -s
echo "KERNEL==\"mali\", MODE=\"0660\", GROUP=\"video\"" > /etc/udev/rules.d/50-mali.rules
adduser misko video
1 Like

Thank you!
Now I successfully encode 3840x2160@60 NV12 with command
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=NV12,height=2160,width=3840,framerate=60/1 ! mpph265enc ! filesink location=test.mp4 .

And encode 1920x1080@60 BGR with command
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=BGR,width=1920,height=1080,framerate=60/1 ! videoconvert ! videoscale ! video/x-raw,width=1920,height=1088,format=NV12,framerate=60/1 ! mpph265enc ! filesink location=test2.mp4.

The 2160p video is perfect, but the 1080p video has a wrong framerate, much much faster than origin source, looks like it drops a lot frames after convert.

1 Like

I do one test about HDMI IN.

And shows this. Didn’t see error log.

root@rock-5b:/home/rock# gst-launch-1.0 v4l2src device=/dev/video0 ! queue ! video/x-raw,format=BGR,height=1080,width=1920  ! mpph264enc ! filesink location=test.mp4
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
rga_api version 1.7.3_[6]
0:01:50.4 / 99:99:99.

I copy test.mp4 to my PC. And use ffplay to view the video.

ffplay -vcodec h264 test.mp4

This varies as the HDMI source may have different format(BGR/NV12). OP is using an NV12 source and try to record in BGR will fail.

In my experience you have to match the V4L2 source resolution and format exactly or the pipeline will fail. Framerate isn’t important though.