pixop / video-compare

Split screen video comparison tool using FFmpeg and SDL2
GNU General Public License v2.0
889 stars 41 forks source link

Major stuttering during AV1 Playback #42

Closed Razor54672 closed 11 months ago

Razor54672 commented 1 year ago

I was comparing two videos, one encoded with HEVC and another with AV1. However, it plays like a slideshow. Why is this the case?

My laptop has a dedicated GPU and the files run just fine in other players so that isn't the problem here.

image

jonfryd commented 1 year ago

Hmm, good question. I'm wondering if "other players" include FFmpeg's ffplay?

veikk0 commented 1 year ago

From what I can see, this tool doesn't use hardware decoding. So if your CPU isn't fast enough to play back the two video files simultaneously with the included software decoders, slow playback is expected behavior.

Also, ffplay doesn't support hardware decoding, though ffmpeg does (when built with the required libraries).

jonfryd commented 1 year ago

Also, ffplay doesn't support hardware decoding, though ffmpeg does (when built with the required libraries).

So I've been doing a little investigation. It turns out ffplay does have support for hardware decoders (via e.g. -vcodec h264_cuvid); the caveat is that ffplay requires decoded image frames to be copied between GPU and main memory instead of keeping frames on the GPU like ffmpeg. Supposedly it is still faster than CPU decoding which makes it interesting to us, as well. I think decoder selection would be something we can add with relative ease in the future when times allows. Let's keep this issue open until then.

jonfryd commented 12 months ago

I have added functionality in the latest version for finding available decoders (--find-decoders) and setting a specific decoder of both the left and/or right video (via --left-decoder and --right-decoder). This can be used to select a hardware accelerated decoder on supported Nvidia GPUs such as h264_cuvid, hevc_cuvid and av1_cuvid if CUDA support has been compiled into FFmpeg's libraries. I haven't tested if this works in the Windows builds provided here, but in theory it should work - hardware decoding works on the Linux PC in our lab which has a Nvidia GeForce GTX 2080 Ti GPU on both H.264 and HEVC videos.

More info on Nvidia hardware decoding support can be found here: https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new#collapseTwo

EDIT: BTW, I just realized that the shared FFmpeg libraries in the Windows build comes with support for Vulkan and other APIs in addition to CUDA, but I don't have the drivers or hardware to test it. Let me know what works for you guys.

jonfryd commented 12 months ago

Note that these hardware decoders are usually restricted in terms of supported pixel formats - typically only lowest common denominator formats such as yuv420p will work.