[Bug]: FFmpeg vp9_qsv encoder MFXVideoCORE_SyncOperation return MFX_ERR_NOT_ENOUGH_BUFFER
- Dominant language
- C++
- Stars
- 157
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
### Which component impacted?
Encode
### Is it regression? Good in old configuration?
None
### What happened?
1. In Linux use master code of gmmlib/libva/media-driver/onevpl/onevpl-gpu-rt/ffmpeg.
2. Run the 1:N cmd:
`ffmpeg -v verbose \
-init_hw_device vaapi=intel:/dev/dri/renderD128 \
-hwaccel vaapi -hwaccel_output_format vaapi \
-hwaccel_device intel -filter_hw_device intel \
-loglevel info \
-fflags +genpts \
-i "meridian_hdr.mp4" \
-filter_complex \
"[0:v]hwmap=derive_device=qsv,format=qsv,vpp_qsv=deinterlace=2:async_depth=1,split=5[s1][s2][s3][s4][s5]; \
[s1]vpp_qsv=w=1920:h=1080:async_depth=1:scale_mode=1[v1]; \
[s2]vpp_qsv=w=1280:h=720:async_depth=1:scale_mode=1[v2]; \
[s3]vpp_qsv=w=960:h=540:async_depth=1:scale_mode=1[v3]; \
[s4]vpp_qsv=w=768:h=432:async_depth=1:scale_mode=1[v4]; \
[s5]vpp_qsv=w=640:h=360:async_depth=1:scale_mode=1[v5]" \
-map "[v1]" -c:v vp9_qsv -b:v 5000k -minrate:v 5000k -maxrate:v 5000k -bufsize:v 1250k -rc_init_occupancy:v 625k \
-g:v 120 -async_depth:v 1 -refs:v 5 -bf:v 0 -preset:v medium -strict:v 1 -low_power:v 1 \
-flags +global_header+cgop -f mp4 -y "1080p-vp9_qsv.mp4" \
-map "[v2]" -c:v vp9_qsv -b:v 4000k -minrate:v 4000k -maxrate:v 4000k -bufsize:v 1000k -rc_init_occupancy:v 500k \
-g:v 120 -async_depth:v 1 -refs:v 5 -bf:v 0 -preset:v medium -strict:v 1 -low_power:v 1 \
-flags +global_header+cgop -f mp4 -y "720p-vp9_qsv.mp4" \
-map "[v3]" -c:v vp9_qsv -b:v 2500k -minrate:v 2500k -maxrate:v 2500k -bufsize:v 625k -rc_init_occupancy:v 312k \
-g:v 120 -async_depth:v 1 -refs:v 5 -bf:v 0 -preset:v medium -strict:v 1 -low_power:v 1 \
-flags +global_header+cgop -f mp4 -y "540p-vp9_qsv.mp4" \
-map "[v4]" -c:v vp9_qsv -b:v 1500k -minrate:v 1500k -maxrate:v 1500k -bufsize:v 375k -rc_init_occupancy:v 187k \
-g:v 120 -async_depth:v 1 -refs:v 5 -bf:v 0 -preset:v medium -strict:v 1 -low_power:v 1 \
-flags +global_header+cgop -f mp4 -y "432p-vp9_qsv.mp4" \
-map "[v5]" -c:v vp9_qsv -b:v 1000k -minrate:v 1000k -maxrate:v 1000k -bufsize:v 250k -rc_init_occupancy:v 125k \
-g:v 120 -async_depth:v 1 -refs:v 5 -bf:v 0 -preset:v medium -strict:v 1 -low_power:v 1 \
-flags +global_header+cgop -f mp4 -y "360p-vp9_qsv.mp4"`
3. See the error log:
`[vp9_qsv @ 0x5a82e1403540] Invalid FrameType:0
[vost#4:0/vp9_qsv @ 0x5a82e1402840] [enc:vp9_qsv @ 0x5a82e1403440] Error submitting video frame to the encoder
[vost#4:0/vp9_qsv @ 0x5a82e1402840] [enc:vp9_qsv @ 0x5a82e1403440] Error encoding a frame: Invalid data found when processing input
[vost#0:0/vp9_qsv @ 0x5a82e13ee2c0] Task finished with error code: -1094995529 (Invalid data found when processing input)
[vost#0:0/vp9_qsv @ 0x5a82e13ee2c0] Terminating thread with return code -1094995529 (Invalid data found when processing input)
frame=21360 fps= 38 q=-0.0 Lq=-0.0 q=-0.0 q=-0.0 q=-0.0 size= 220461KiB time=00:05:56.33 bitrate=5068.3kbits/s speed=0.635x
Conversion failed!`
4. And checked the err is caused by:
https://github.com/FFmpeg/FFmpeg/blob/96d45c3b212689f82bff2530c3637405df9e9369/libavcodec/qsvenc.c#L2663
The MFXVideoCORE_SyncOperation returns MFX_ERR_NOT_ENOUGH_BUFFER. And the vpl doc doesn't mention this API can and why return MFX_ERR_NOT_ENOUGH_BUFFER:
https://intel.github.io/libvpl/latest/API_ref/VPL_func_vidcore.html#_CPPv426MFXVideoCORE_SyncOperation10mfxSession12mfxSyncPoint6mfxU32
5. The issue only happens on vp9_qsv. hevc_qsv and h264_qsv looks good. And this issue is a re-map of https://github.com/intel/cartwheel-ffmpeg/issues/360
### What's the usage scenario when you are seeing the problem?
Transcode for media delivery
### What impacted?
_No response_
### Debug Information
_No response_
### Do you want to contribute a patch to fix the issue?
None
Contributor guide
Assessment
This issue has not been assessed yet.