Opened 8 months ago

Closed 8 months ago

Last modified 8 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


Summary of the bug:

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


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  ( master )
iHD Driver	ed04556a6676fd77ff845508bc54bfc60915450c
libva-utils	9a10ad663349732decd668a426cfc349b0010d1d
Mediasdk	7ea683585f0f84f1bea035a405855312c92c46c0
FFMPEG	56f68a099cc607658118e00cad30569103ae3751

How to reproduce: 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


Change History (4)

comment:1 Changed 8 months ago by cehoyos

  • Keywords look_ahead_depth removed

Why do you think this is a bug?

comment:2 Changed 8 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 8 months ago by zhuqingliang

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

comment:4 Changed 8 months ago by lizhong1008

Note: See TracTickets for help on using tickets.