bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.45k stars 1.57k forks source link

Failed to decode h264 frame with DXVA2.0 because returned buffer is to small #2028

Open grill2010 opened 1 year ago

grill2010 commented 1 year ago

I have to admit that this might not be directly related to javacv as it might be a general ffmpeg problem but not 100% sure. There was recently a fix for the MAX_SLICES problem but it seems that DXVA2 still has problems to decode certain keyframes because the buffer returned from IDirectXVideoDecoder_GetBuffer is too small. Not sure what exactly is causing this issue but the logs from ffmpeg is printing out this

Error: [h264 @ 000001ba121896c0] Buffer for type 5 was too small. size: 58752, dxva_size: 55296 Error: [h264 @ 000001ba121896c0] Failed to add bitstream or slice control buffer Error: [h264 @ 000001ba121896c0] hardware accelerator failed to decode picture

All other decoder like D3D11VA, Cuvid or the software decoder have absolutly no problem with the keyframe. Seems to be only an issue with DXVA2. I hava a self compiled java-preset ffmpeg version so I could start to play around with some things but I don't have any idea where to start with. It might be possible that a patch could solve that problem.

I have a minimal reproducable example available here. All the logic can be found in the App.java class, instructions are in the README. When you execute the example you should receive a SUCESS with HW decoding message instead of the errors above.

Is this a known limitation of DXVA2? Anyone knows why the returned buffer might be too low?

streamingdv commented 1 year ago

@saudet I could reproduce the problem on two PCs with Nvidea graphics cards. I tried now on a 3rd device with an Intel GPU and surprisingly it works without any issues? I'm wondering what is the root cause here? Windows, drivers or something else? Any chance you can try the example on a Windows machine as well? Just curious what would be the results?

saudet commented 1 year ago

Please report upstream! BTW, for NVIDIA, we can use NVDEC/CUVID.

streamingdv commented 1 year ago

@saudet sure will do, where exactly should I report this? What would be the best option here? (Sorry for the stupid question) Yes I know, cuvid works perfectly fine.

saudet commented 1 year ago

https://ffmpeg.org/bugreports.html

streamingdv commented 1 year ago

FYI

https://trac.ffmpeg.org/ticket/10374#no1