wang-bin / QtAV

A cross-platform multimedia framework based on Qt and FFmpeg. 基于Qt和FFmpeg的跨平台高性能音视频播放框架. Recommand to use new sdk https://github.com/wang-bin/mdk-sdk
http://qtav.org
3.98k stars 1.5k forks source link

Performance / HW acceleration #547

Open bongas opened 8 years ago

bongas commented 8 years ago

I'm trying to get as good performance with QtAV as possible. When trying to play a high resolution video using QtAV it's quite choppy. When I play the same video in VLC it's perfectly smooth. In VLC i have discovered that there are two different hardware acceleration settings: HW decoding and "Accelerated video output (overlay)". It seems that disabling the latter makes the video choppy even in VLC while the HW decoding seems to make less difference (the CPU load is of course lower with HW decoding).

Without "HW overlay" in VLC the quality is pretty much the same as in QtAV which leads me to think that this "hardware overlay" is not used in QtAV, correct? Or is this the same as "Zero copy" copy mode? Further, it seems that the output mode in VLC that gives best performance is "XVideo output (xcb)". XVideo (X video extension or xv) seems to be used mainly for scaling the video, which makes me think that it is the scaling that makes the video choppy using QtAV. Can QtAV utilize XVideo?

I'm running Ubuntu 14.04 on a Intel GPU (Intel HD5500) using the latest QtAV.

What should be the best setup - performance wise? VAAPI with display: X11, copy mode: "Zero copy" (the default)? Would EGL make any difference?

Thanks /Gabriel

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28710538-performance-hw-acceleration?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github).
wang-bin commented 8 years ago

show me your log. vlc's vaapi does not support vlc. It will copy the video frame from gpu to host memory and then upload to gpu. zero copy does not require such copy back and upload. so it should be faster and less cpu usage. xvideo is already supported. run player -vo xv. With the latest code and qt5.5, you can use egl to get the best performance. How did you install qtav? ppa or your own build?

bongas commented 8 years ago

I have now upgraded the computer to run Ubuntu 15.10 with all the latest drivers. Unfortunately the video is still choppy. I have tried to use the XV renderer like VLC but VLC still produces almost perfect video while QtAV is a bit choppy. The log from when I run the player example: http://pastebin.com/7FyLV2MT I use the latest QtAV which I have compiled myself with Qt5.5. If I check the FPS now in media info it's 60 so it seems that the computer have enough power to render it.

Here is the video: https://drive.google.com/file/d/0BwTlBKoEwt-sWVpCbVBiM09SQnc/view?usp=sharing It's a quite high resolution video with water which is very sensitive for choppyness...

Another note: When trying OpenGLWidget as render together with EGL, the image is green-ish. What could cause that?

Thanks /Gabriel

wang-bin commented 8 years ago

I don't fill choppiness. Running on ubuntu 15.10 with intel HD4600. The fps shows 60 but still choppy? What about ffmpeg software decoder? ffmpeg decoder looks fine too in my test.

To use egl in QtAV you have to run git submodule update --init first then rebuild. The most efficient way is egl+vaapi+opengl renderer.

wang-bin commented 8 years ago

Can you record a short video of the choppy playback?

bongas commented 8 years ago

I have done a lot more testing now and I have succeeded in getting better performance after changing some settings. Still it's not as smooth as VLC but pretty close.

I have increased the bufferValue in AVPlayer to a very high number (like 20000) which makes the rendering much more fluid. How can that be? I also needed to add the "TearFree" option for Intel hardware (in Xorg config) to make it even better. This test movie (https://drive.google.com/file/d/0BwTlBKoEwt-saGpuTDQ5Z1ZzZ28/view?usp=sharing) made the tearfree option very obvious (with tearfree it is almost perfectly smooth but without it was very choppy and ragged).

I get best performance with the above settings and OpenGLWidget+VAAPI+GLX display. EGL still has wrong colors even after the re-compile you suggested. Do you have any other idea what the cause could be?

Highly appreciated - thanks! /Gabriel

wang-bin commented 8 years ago

I need your log. Both GLX and EGL. No special option should be required to play smoothly.

export QTAV_LOG=all
./player