ffmpeginteropx / FFmpegInteropX

FFmpeg decoding library for Windows 10 UWP and WinUI 3 Apps
Apache License 2.0
211 stars 53 forks source link

decode P frame #247

Closed lihongyi1234 closed 2 years ago

lihongyi1234 commented 2 years ago

thanks for your project, I find a problem that if there is many P frames, then decode P frames failed, i cant get the correct frames

lukasf commented 2 years ago

Hi, well, that's by definition how P frames work. They highly depend on the previous frame. If one frame is broken due to data corruption or encoding errors, then all following P frames will be broken as well, until the next I frame is decoded. We cannot do anything about that.

lihongyi1234 commented 2 years ago

happy to receive your reply, first my problem is that you project can not decode P frame, finally i find your project can't decode P frame that encoded by baseline (profile), if mp4 encoded by main (profile), it's ok. i just find this situation but i don't know why

lukasf commented 2 years ago

If all P-frames fail to decode, then there is a problem with the specific file encoding you have. We use ffmpeg as decoding library, and of course generally it can decode P-frames very well. Either you have a bad encode, or there is a bug in the ffmpeg lib version we are currently using.

If you can upload a sample file, we could investigate further.

Oh and you can also try to disable hardware decoding. In the sample app, there is a slider for that. Maybe it is only the GPU that fails to decode, and software decoding through ffmpeg would work.

lihongyi1234 commented 2 years ago

yes i decode with GPU In pursuit of performance, software decoding is ok i tested. it seems the resolution is very high test.zip

lukasf commented 2 years ago

Somehow I forgot about this one, sorry @lihongyi1234

I have just tested the file. The file is only few seconds long, I hope this is the right file. It plays find on my machine with HW acceleration enabled. I tried on both Intel iGPU and NVidia dGPU. It must be a limitation of your GPU, that it somehow cannot cope with the high resolution or encoding settings.

lukasf commented 2 years ago

Hi @lihongyi1234, I recently found a file where I had broken P frames with HW acceleration. I found out that the problems went away when I disabled multi threading. Using CPU multi threading does not make sense when GPU does the decoding. Usually the codecs will internally disable multi threading, but some do not, as it seems.

If you want to test this, you can try the ffmpeg-5.0 branch, it contains the changeset.

lukasf commented 2 years ago

I think this is solved, closing this...