Getting frame loss and bad frames using h264EncoderDemo on hardware encoder

Hi Folks,

I am working on validating hardware video encoder in the VIM3L.
I am using Linux Khadas 4.9.241 kernel and image is created using fenix.
I found that VIM3L has the Library and test application for that. I got it from

https://github.com/numbqq/encoder_libs_aml

I used downloaded video <sunflower_1080p25.y4m> and tried to encode using following command

./h264EncoderDemo ~/sunflower_1080p25.y4m test.h264 1920 1080 10 30 2000000 500 1

and getting frame drops in encoded video, getting frame overlapping and worst quality.

I have attached picture for reference.

There is a readme file but it is not so helpful.

It would be appreciated if pointers are given to move ahead.

Thanking you in anticipation.





Please check the encoding documentation here:

Hi @numbqq,
Thank you for the reference, I am referring the same document and get some improvement by changing

fmt

parameter. but still my video is play as pic slide animation. it’s look like a picture is sliding from left to right.

I have attached pictures for reference.





Any reference image/video suggested from Khadas for testing ?

I have used YUV(i420) 1920x1080@25 fps

Can you give pointers related to this?

Here is a NV12 format test video, you can use this video to check. https://dl.khadas.com/test/1080p.nv21.7z

Just follow the instructions from the documentation.

H264:

$ h264EncoderDemo  1080p.nv21    1080p.h264 1920 1080 10 30 2000000 2000 1

Does your test video is I420 YU12 format ? The test demo only support YU12 I420.
And you can also check other format on your side, e.g. NV12 or NV21.

And please also provide your test video for us to check.

Thanks for your quick reply.
I will test your video soon.

I have downloaded video using
https://media.xiph.org/video/derf/y4m/sunflower_1080p25.y4m

I also tested with direct output of webcam in YUYV 4:2:2 format and not get expected result.

fmt : encode input fmt 0:nv12 1:nv21 2:i420 (yu12) 3:rgb888 4:bgr888\n ");

你试着把命令最后面的1 改成2 试试?你要根据你输入的yuv 格式,选择对应的fmt

yes, I had tried with 2

Please check the demo help message for supported formats.
H264 only supoport : 0:nv12 1:nv21 2:i420 (yu12) 3:rgb888 4:bgr888 input now, if you use other format you have to convert to such format or you can modify the encoder library.

I checked with your video, you can convert your video to I420(YU12) format and use the encoder demo to encode.

Covert video to YU12:

$ ffmpeg -i sunflower_1080p25.y4m -s 1920x1080 -pix_fmt yuv420p sunflower_1080p25.yuv

Encode:

$ h264EncoderDemo sunflower_1080p25.yuv 1080p.h264 1920 1080 10 30 2000000 2000 2

@numbqq Thanks for your valuable reply, I would like to add support for the required format as converts the format before encoding is cpu and time consuming process.

Can you please give some pointers for adding support of new format in library?

Also, is there any plan to integrate hardware encoder with Gstreamer?

1 Like