Opened 2 months ago

Closed 2 months ago

Last modified 2 months ago

#7426 closed defect (invalid)

[ffmpeg-qsv][avc encode] "-look_ahead_depth 100" cause "Cannot allocate memory"

Reported by: zhuqingliang Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: qsv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

 if set "-look_ahead_depth N"  N too big , it will cause "Cannot allocate memory".  

environment

CFL	OS: ubuntu 17.04	kernel: 4.15.0
	KBL	OS: ubuntu 16.04	kernel: 4.14.0-rc1
	SKL	OS: ubuntu 16.04	kernel: 4.15.0
			
libva	b6c50dad4d7d14c507108d9f468662e2d7ae1c4d	 https://github.com/01org/libva.git  ( master )
iHD Driver	ed04556a6676fd77ff845508bc54bfc60915450c	 https://github.com/intel/media-driver
libva-utils	9a10ad663349732decd668a426cfc349b0010d1d	 https://github.com/01org/libva-utils.git
Mediasdk	7ea683585f0f84f1bea035a405855312c92c46c0	 https://github.com/Intel-Media-SDK/MediaSDK
FFMPEG	56f68a099cc607658118e00cad30569103ae3751	 https://git.ffmpeg.org/ffmpeg.git

How to reproduce:

1.build env as above lists
2.ffmpeg -hwaccel qsv -init_hw_device qsv=hw -filter_hw_device hw -v verbose -f rawvideo -video_size 352x288 -pix_fmt nv12 -i ./30_298frame_352x288_mobile.yuv -an -vf hwupload=extra_hw_frames=64,format=qsv -c:v h264_qsv -framerate 30 -b:v 200k -profile:v main -preset 4 -look_ahead 1 -look_ahead_depth 56 -y ./H264e_352x288_200k_preset4_LA50.h264
3.error message:
[hwupload @ 0xa615c0] Failed to allocate frame to upload to.
Error while filtering: Cannot allocate memory
Failed to inject frame into filter network: Cannot allocate memory
Error while processing the decoded data for stream #0:0

fail case

H264e_352x288_200k_preset4_LA100.h264
H264e_720x480p_1m_preset4_LA100.h264
H264e_1280x720p_2M_preset4_LA100.h264
H264e_1920x1080p_4M_preset4_LA100.h264
H264e_4096x2304_15M_preset4_LA100.h264

Change History (4)

comment:1 Changed 2 months ago by cehoyos

  • Keywords look_ahead_depth removed

Why do you think this is a bug?

comment:2 Changed 2 months ago by jkqxz

  • Resolution set to invalid
  • Status changed from new to closed

Since libmfx does not support dynamic sizing of frame pools, extra_hw_frames is needed to set how many frames will be available in the pool created by hwupload which is then used at the encoder input. Setting a high lookahead depth means the encoder will consume a large number of frames without returning them, so if extra_hw_frames is not large enough the pool will be exhausted as indicated by the error message above.

Set extra_hw_frames to reflect how many frames you actually intend to use. With a lookahead depth of 100 you need at least 100, and probably more because the encoder will also store past frames to use for reference.

comment:3 Changed 2 months ago by zhuqingliang

I change from "-extra_hw_frames=64" to "120" , this issue is gone.
Thank you very much.

comment:4 Changed 2 months ago by lizhong1008

Note: See TracTickets for help on using tickets.