MPP(h265enc) ignoring rc-mode

Hi, I’m having a few issues with mpph265enc (I’m on the latest debian image)
When changing the bitrate, there is no actual change, also there is no error or debug information, it just doesn’t do it.

ps I also tried the bitrate in actual kbps (8000) but it still isn’t working, it is not affected by any change I do there
changing resolution works without issue, but the rc-mode is just not doing anything, I also tried bps-max … and still completely ignored.

I also tried compiling mpp from source, no change

My pipeline is gst-launch1.0 v4l2src device=/dev/video11 io-mode=auto do-timestamp=true ! video/x-raw,format=NV12, framerate=30/1 ! mpph264enc rc-mode=cbr bps=8000000 width=640 height=480 rotation=0 gop=5 ! queue ! h264parse config-interval=-1 ! rtph264pay mtu=1440 ! appsink drop=true name=out_appsink

@Raphael

I think that depends on your gstreamer version.

What is the output of (after you run the command):
sudo journalctl --no-pager -n 50

Mine is telling the encoder all the parameters you want encoder to do.

Patched gstreamer, of course:

gst-launch-1.0 version 1.20.3
GStreamer 1.20.3
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

The problem with that is that the isp doesn’t work correctly in ubuntu :confused:

In debian/bullseye we only have 1.18.5
and there are no hints in the journalctrl that something doesn’t work

Rockchip supports the latest gstreamer on Debian sid but you need to apply their patches.
Here is the patch set: https://github.com/JeffyCN/rockchip_mirrors/tree/buildroot/package/gstreamer1

Please, don’t assume isp doesn’t work correctly in ubuntu, you are going in the wrong direction with the image you are using (which one?).

It won’t tell you that is not working but you can see all parameters are passed to mpp:

rock5b mpp[2730]: mpp_enc: MPP_ENC_SET_RC_CFG bps 8000000 [7500000 : 8500000] fps [30:30] gop 5
rock5b mpp[2730]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [640:480] stride [640:480]
rock5b mpp[2730]: mpp_enc: mode cbr bps [7500000:8000000:8500000] fps fix [30/1] -> fix [30/1] gop i [5] v [0]
rock5b rkaiq[319]: DBG: /dev/media1: wait stream start event success ...
rock5b kernel: rkisp_hw fdcb0000.rkisp: set isp clk = 594000000Hz
rock5b rkaiq[319]: DBG: /dev/media1: wait stream stop event...
rock5b kernel: rkcif-mipi-lvds2: stream[0] start streaming

And this is on Ubuntu 22.04, you can check if it worked:
out_640x480.h264.zip (804.3 KB)

BTW, have you seen the latest work in FFmpeg encoder?

Here the gstreamer log with kernel rkr4.1:

rock5b mpp[3051]: mpp_enc: MPP_ENC_SET_RC_CFG bps 8000000 [7500000 : 8500000] fps [30:30] gop 5
rock5b mpp[3051]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [640:480] stride [640:480]
rock5b mpp[3051]: mpp_enc: mode cbr bps [7500000:8000000:8500000] fps fix [30/1] -> fix [30/1] gop i [5] v [0]
rock5b kernel: rkisp_hw fdcb0000.rkisp: set isp clk = 594000000Hz
rock5b rkaiq[319]: DBG: /dev/media1: wait stream start event success ...
rock5b rkaiq[319]: DBG: /dev/media1: wait stream stop event...
rock5b kernel: rkcif-mipi-lvds2: stream[0] start streaming
rock5b kernel: rockchip-mipi-csi2 fdd30000.mipi2-csi2: stream on, src_sd: 000000000731bd23, sd_name:rockchip-csi2-dphy0
rock5b kernel: rockchip-mipi-csi2 fdd30000.mipi2-csi2: stream ON
rock5b kernel: rockchip-csi2-dphy0: dphy0, data_rate_mbps 892
rock5b kernel: rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream stream on:1, dphy0
rock5b kernel: rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream stream on:1, dphy0
rock5b kernel: imx415 3-001a: s_stream: 1. 3864x2192, hdr: 0, bpp: 10
rock5b kernel: imx415 3-001a: set vblank 0x3a vts 2250
rock5b kernel: imx415 3-001a: set exposure(shr0) 225 = cur_vts(2250) - val(2025)
rock5b kernel: imx415 3-001a: set analog gain 0x36
rock5b kernel: imx415 3-001a: set analog gain 0x35
rock5b kernel: imx415 3-001a: set analog gain 0x33
rock5b kernel: imx415 3-001a: set analog gain 0x32
rock5b kernel: imx415 3-001a: set analog gain 0x31
rock5b kernel: imx415 3-001a: set analog gain 0x30
rock5b kernel: rkcif-mipi-lvds2: stream[0] start stopping, total mode 0x2, cur 0x2
rock5b kernel: rockchip-mipi-csi2 fdd30000.mipi2-csi2: stream off, src_sd: 000000000731bd23, sd_name:rockchip-csi2-dphy0
rock5b kernel: rockchip-mipi-csi2 fdd30000.mipi2-csi2: stream OFF
rock5b kernel: rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream_stop stream stop, dphy0
rock5b kernel: rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream stream on:0, dphy0
rock5b kernel: rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream stream on:0, dphy0
rock5b kernel: imx415 3-001a: s_stream: 0. 3864x2192, hdr: 0, bpp: 10
rock5b kernel: rkcif-mipi-lvds2: stream[0] stopping finished, dma_en 0x0
rock5b rkaiq[319]: DBG: /dev/media1: wait stream stop event success ...
rock5b rkaiq[319]: DBG: device manager start
rock5b rkaiq[319]: DBG: rkisp_init engine succeed
rock5b rkaiq[319]: DBG: /dev/media1: wait stream start event...
rock5b kernel: rkisp rkisp0-vir0: first params buf queue
rock5b kernel: rkisp0-vir0: waiting on params stream off event timeout

I realized your title is about h265 and your pipeline is h264.
So i run again with h265. Playing it shows the video at ~ 2037 kbps. Recording at bps=18000000 the result is about 4000 kbps . Looks like it auto adjust.

out_640x480.h265.zip (3.3 MB)

@avaf Thanks for the detailed answers, I don’t assume that the isp doesn’t work, but the Radxa-devs told me to not use the ubuntu images when using the isp. They told me it wasn’t implemented right.

And since I’m working on camera-support for new cameras, I need a point to start. And now that I got the isp working with my custom drivers, kernel and overlay’s I don’t want to redo everything again. So my information is from @RadxaYuntian and not an assumption.

Now I have the problem of working camera but no working encoding, which is … quite annoying to be honest.

@Pipelines, you’re right I posted the h264 pipeline, in general I tried h265 and h264 having the same issues (I have multiple test pipelines)

Now I’m looking to build the newest gstreamer version for the bullseye image and trying to retest the whole thing.

@FFmpeg, I can’t use ffmpeg + most industrial solutions want to use gstreamer

@auto adjust … cbr means constant bitrate, any adjustment is a failure in that regard

I see, Rockchip’s official support is on Debian, that’s what they mean by not using Ubuntu.
gstreamer is powerful and modular, i agree but it’s hard to use programmatically (you need to be a wizard), but most industrial solutions want to use gstreamer is new to me, but maybe i don’t know any, it’s just my personal view. I just see they want to get away from any potential license issue with FFmpeg.

Anyway, wish you release your work on the new cameras soon…

finally made a log via journalctl

Aug 06 22:44:49 openhd mpp[1113]: mpp_info: mpp version: 2edfc6db author: Chandler Chen 2022-11-22 [vepu540c_hevc]: fix argb8888 encode error
Aug 06 22:44:49 openhd mpp[1113]: mpp_info: mpp version: 2edfc6db author: Chandler Chen 2022-11-22 [vepu540c_hevc]: fix argb8888 encode error
Aug 06 22:44:49 openhd mpp[1113]: mpp_info: mpp version: 2edfc6db author: Chandler Chen 2022-11-22 [vepu540c_hevc]: fix argb8888 encode error
Aug 06 22:44:49 openhd mpp[1113]: mpp_info: mpp version: 2edfc6db author: Chandler Chen 2022-11-22 [vepu540c_hevc]: fix argb8888 encode error
Aug 06 22:44:49 openhd mpp[1113]: mpp_info: mpp version: 2edfc6db author: Chandler Chen 2022-11-22 [vepu540c_hevc]: fix argb8888 encode error
Aug 06 22:44:49 openhd mpp[1113]: mpp_enc: MPP_ENC_SET_RC_CFG bps 8000000 [7500000 : 8500000] fps [30:30] gop 5
Aug 06 22:44:49 openhd mpp[1113]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [640:480] stride [640:480]
Aug 06 22:44:49 openhd mpp[1113]: mpp_enc: mode cbr bps [7500000:8000000:8500000] fps fix [30/1] -> fix [30/1] gop i [5] v [0]

looks like it is still the old version of mpp … maybe there is the issue

mpp_info: mpp version: f1734a1 author: Yandong Lin 2023-06-08 [mpp_service]: remove get disable_rcb_info env runtime

Aug 07 00:32:30 openhd openhd[2090]: [2023-08-07 00:32:30.200] [v_gststream] [debug] Starting pipeline:[v4l2src device=/dev/video11 io-mode=auto do-timestamp=true ! video/x-raw,format=NV12, framerate=30/1 ! mpph264enc rc-mode=cbr bps=6000 width=1920 height=1080 rotation=0 gop=5 ! queue ! h264parse config-interval=-1 ! rtph264pay mtu=1440 !  appsink drop=true name=out_appsink]
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_enc: MPP_ENC_SET_RC_CFG bps 6000 [5625 : 6375] fps [30:30] gop 5
Aug 07 00:32:30 openhd mpp[2090]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [1920:1080] stride [1920:1088]
Aug 07 00:32:30 openhd mpp[2090]: mpp_enc: mode cbr bps [5625:6000:6375] fps fix [30/1] -> fix [30/1] gop i [5] v [0]
root@openhd:/opt# journalctl | grep mpp
Aug 07 00:32:30 openhd openhd[2090]: [2023-08-07 00:32:30.200] [v_gststream] [debug] Starting pipeline:[v4l2src device=/dev/video11 io-mode=auto do-timestamp=true ! video/x-raw,format=NV12, framerate=30/1 ! mpph264enc rc-mode=cbr bps=6000 width=1920 height=1080 rotation=0 gop=5 ! queue ! h264parse config-interval=-1 ! rtph264pay mtu=1440 !  appsink drop=true name=out_appsink]
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_info: mpp version: 3418cca5 author: Raphael       2023-07-30 Update build_chroot.sh
Aug 07 00:32:30 openhd mpp[2090]: mpp_enc: MPP_ENC_SET_RC_CFG bps 6000 [5625 : 6375] fps [30:30] gop 5
Aug 07 00:32:30 openhd mpp[2090]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [1920:1080] stride [1920:1088]
Aug 07 00:32:30 openhd mpp[2090]: mpp_enc: mode cbr bps [5625:6000:6375] fps fix [30/1] -> fix [30/1] gop i [5] v [0]

new version (selfcompiled), no change bitrate is 17Mbit, fixed