No able to encode a YUV video stream on imx8 M Plus

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

No able to encode a YUV video stream on imx8 M Plus

1,304 Views
vinay_hasyagar
Contributor III

Hi,

We are using i MX8 M Plus (iMX 8 M Plus Evk) for encode and decode of video stream. We generated Yocto image based on 5.10-hardknott and kernel version is Linux 5.10.72-lts-5.10.y+ga68e31b63f86 . We tried encode/decode examples which are present in https://github.com/NXP/imx-vpuwrap  in which decode works fine where as encode does not.

For encoding we gave input as a .yuv file which has YUV420 format and WxH as 352x288 with codec as h264. Below is the command.

./test_enc_arm_elinux -i stefan_cif.yuv -o /tmp/encode.h264 -f 2 -h 288 -w 352 

We are getting the below error

input YUV file : stefan_cif.yuv
max frame number : 2147483647
vpu lib version : major.minor.rel=1.1.1
vpu fw version : major.minor.rel_rcode=1.1.1_r65535
vpu wrapper version : major.minor.rel=3.0.0: VPUWRAPPER_ARM64_LINUX Build on Mar 3 2022 17:24:31
EWLMallocLinear pewl 0xaaab007571d0, size 10489856, virt 0xffffa8a8f000 phy 0xd4900000
using VPU_EncOpenSimp Interface
VPU_EncOpen param w 352 h 288 bitrate 0 gop 15 frame rate 30 qpmin 0 qpmax 0
open H264
Init OK: min buffer cnt: 0, alignment: 1
EWLMallocLinear pewl 0xaaab00768480, size 155648, virt 0xffffa89e5000 phy 0xd48c0000
EWLMallocLinear pewl 0xaaab00768480, size 155648, virt 0xffffa89bf000 phy 0xd5340000
EncodeLoop: encode frame : input is not used
CallBack_EncOneFrameOK: one frame is OK , length: 36
Frame type I, Frame counter (0)
rcCfg.qpHdr 26rcCfg.bitPerSecond 486000
VCEncStrmEncode: ERROR Invalid input busChromaU
VCEncStrmEncode returned VCENC_INVALID_ARGUMENTVPU_EncDoEncode return 2
VPU_EncEncodeFrame DoEncode return error 2
encode_stream: vpu reset: handle=0x756C50
**** vpu enc: total frame 0 encode time 0 fps nan
Frame Num: 0, [width x height] = [352 x 288], enc FPS: 0, total FPS: 0
Encode Failure

We tried example which is present in /unit_tests/VPU/hantro/  but got a different error

./vc8000e_h264enc -i stefan_cif.yuv -o /tmp/encode.h264 -w 352 -h 288 -O 0

Below is the error

HEVC Encoder API version 2.2
HW ID: 0x80006200 SW Build: 43.14.10
Get rate control: qp 17 qpRange I[ 0, 51] PB[ 0, 51] 1000000 bps pic 0 skip 0 hrd 0 cpbSize 1000000 bitrateWindow 150 intraQpDelta -5
Set rate control: qp -1 qpRange I[ 0, 51] PB[ 0, 51] 1000000 bps pic 0 skip 0 hrd 0 cpbSize 1000000 bitrateWindow 150 intraQpDelta -5 fixedIntraQp 0
Get PreP: input 352x288 : offset 0x0 : format 0 : rotation 0cc 0 : scaling 0
Set PreP: input 352x288 : offset 0x0 : format 0 : rotation 0cc 0 : scaling 0 : scaling format 0
VCEncSetTestId# ERROR, testing disabled at compile time
tb->extSRAMMemFactory[coreIdx].virtualAddress=0xffff88991000,busAddr=0xd4970000
Input buffer[0] size: 155648 bytes
Input buffer[0] bus address: 0xd4940000
Input buffer[0] user address: 0xffff88a38000
Output buffer[0] size: 622592 bytes
Output buffer[0] bus address: 0xd4a00000
Output buffer[0] user address: 0xffff8899f000
Reading input from file <stefan_cif.yuv>, frame size 152064 bytes.
=== Encoding 0 stefan_cif.yuv codeType=0 ...
=== Encoded 0 bits=405840 TotalBits=406152 averagebitrate=12184560 HWCycles=373579 Time(us 1221 HW +SW) maxSliceBytes=50730
=== Encoding 1 stefan_cif.yuv codeType=1 ...
=== Encoded 1 bits=176512 TotalBits=582664 averagebitrate=8739960 HWCycles=167825 Time(us 510 HW +SW) maxSliceBytes=22064
=== Encoding 2 stefan_cif.yuv codeType=1 ...
=== Encoded 2 bits=183240 TotalBits=765904 averagebitrate=7659040 HWCycles=170639 Time(us 476 HW +SW) maxSliceBytes=22905
=== Encoding 3 stefan_cif.yuv codeType=2 ...
VCEncStrmEncode: Invalid coding format, B frame not supported by core
VCEncStrmEncode: Invalid coding format not supported by HW
Error: ../hevc/test_bench.c, line 860: encode() fails

I am attaching the sample yuv file that's been used

Please help us to solve the issue

Our main question is, does iMX8M Plus really support imx-vpuwrapper hardware video decode and encode? 

Thank you

Tags (1)
0 Kudos
4 Replies

1,164 Views
pete_sensoray
Contributor II

I found the solution for vc8000e_h264enc while investigating the source code vpu_wrapper_hantro_VCencoder.c:

pObj->config.gopSize = 1; /* make sure no B frame */

Try this:

/unit_tests/VPU/hantro/vc8000e_h264enc -i stefan_cif.yuv -o /tmp/encode.h264 -w 352 -h 288 -O 0 --gopSize 1

 

0 Kudos

1,159 Views
vinay_hasyagar
Contributor III

@pete_sensoray  Thank you for your suggestion. We will look into it

0 Kudos

1,188 Views
pete_sensoray
Contributor II

I'm having the same problem with 5.10-gatesgarth.

0 Kudos

1,278 Views
vinay_hasyagar
Contributor III

Any solution for this??

0 Kudos