i.MX8MM h264 encoder bitrate higher than asked in gstreamer CBR mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX8MM h264 encoder bitrate higher than asked in gstreamer CBR mode

1,411 Views
pyh0603
Contributor III

Hi everyone,

I now use GStreamer for video coding and RTSP protocol for transmission. In the encoding process, call the plug-in "vpuenc_h264" and set the static rate 4M, as shown in the following figure.

1.png

If the image of the camera does not change, the code rate range is generally about 4m, with a change of about 20%, which is normal. As shown in the figure below:

2.png

However, if the camera is covered by hand and then released, the change range of bit rate is 0.5m ~ 20m, which is 5 times the set value. The range is too large and is abnormal

3.png4.png

vpuenc_h264 components have only a few parameters to set: qos, bitrate, gop-size,quant. I have set the parameters gop-size and quant, but the test results have no effect on the bit rate.

Is there any measure to keep this bit rate in a fixed range under any changing video source?

 

Thankyou!

Look forward to your reply!

Labels (1)
0 Kudos
4 Replies

1,407 Views
igorpadykov
NXP Employee
NXP Employee

Hi Peng

 

may be useful to look at sect.8.3. V4l2 Encode and Decode Extra Properties below document

and try with latest Linux 5.10.35_2.0.0 release

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/i-MX-8-Camera-Use-Cases/ta-p/1117352

https://www.nxp.com/design/software/embedded-software/i-mx-software/embedded-linux-for-i-mx-applicat...

 

Best regards
igor

0 Kudos

1,387 Views
pyh0603
Contributor III

Thank you for your reply.

"may be useful to look at sect.8.3. V4l2 Encode and Decode Extra Properties below document"

v4l2h264enc  element just for  i.MX 8QM MEK and the i.MX 8QXP MEK only. but we use imx8MM evk

 

"try with latest Linux 5.10.35_2.0.0 release"

I have tested Linux 5.10.35_ 2.0.0, but this version has the same problems as the Linux version 4.14.98-05983-g5d6cbea-dirty I currently use. The GStreamer CBR model was not significantly improved

 

Are there other measures to optimize the CBR mode of GStreamer in a fixed range under any changing video source?

 

Thank you!

Look forward to your reply!

0 Kudos

1,379 Views
igorpadykov
NXP Employee
NXP Employee

Vpu will try to encode the clips based on target bitrate as possible.
If the target bitrate is too small or too large, the vpu can’t get the correct target bitrate specified by user.
In general, there is no good method to know the proper bitrate before encoding. Useful links:

https://community.nxp.com/t5/i-MX-Processors/What-s-the-right-configuration-of-iMX53-vpu-that-can-ge...

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Q-A-i-MX6-VPU-Bitrate/ta-p/1107421

For "vpuenc_h264" one can try :

gst-launch-1.0 filesrc location=video.mp4 typefind=true ! video/quicktime ! qtdemux ! queue max-size-time=0 ! vpudec ! queue ! vpuenc_h264 bitrate=20000 ! h264parse ! filesink location=test.h264

For bitrate control one can refer to  i.MX VPU API Reference Manual​

or gst1.0-plugins sources

https://source.codeaurora.org/external/imx/gst1.0-plugins-fsl/tree/plugins/vpu/gstvpuenc.c?h=nxp/MM_...

 

Best regards
igor

0 Kudos

1,367 Views
pyh0603
Contributor III

Thank you for your reply

"For "vpuenc_h264" one can try :"
You use the GStreamer command line for coding. We use an RTSP server similar to the command line on i.MX8MM EVK.
We refer to an open source RTSP service:https://github.com/Gateworks/gst-gateworks-apps

run command:
./gst-variable-rtsp-server "v4l2src device=/dev/video0 ! video/x-raw,width=1920,height=1080,framerate=(fraction)30/1 ! imxvideoconvert_g2d ! video/x-raw,width=1920,height=1080 ! videorate ! video/x-raw ,framerate=(fraction)30/1 ! vpuenc_h264 bitrate=4096 ! rtph264pay name=pay0 pt=96"


As shown on the command line, we have set the bitrate to 4096kbps,

If video stream source changes little, the output bitrate of the RTSP video source is about 4096kbps, which is good.

However, if the video stream source changes greatly, the output bitrate of the RTSP video source is in the range of 400kbps ~ 24000kbps

i.MX8MM h264 encoder bitrate higher than specified by user in gstreamer CBR mode

 

your mean, there's no measures to optimize the CBR mode of GStreamer in a fixed range under any changing video source ?

 

Thank you!

Look forward to your reply!

0 Kudos