[QWebView] HTML5 video with Hardware Decoding
-
wrote on 15 Oct 2014, 08:13 last edited by
I use html5 to play a H.264 video in QWebView, but it uses software decode.
How to use hardware decode instead?My main function and html are like below:
@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebView *view = new QWebView();
view->setGeometry(0,0,1024,1000);
view->load(QUrl("qrc:/html5/html5_video.html?init=true"));
view->show();return a.exec();
}@
@<video width="854" height="480" src="file:///media/video/test.mp4" controls></video>@Thanks!
-
wrote on 15 Oct 2014, 09:50 last edited by
Hi,
i'm not sure but try this:
@view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);@ -
wrote on 15 Oct 2014, 10:06 last edited by
Thanks Vovasty, but after adding this, the video is still lag...
-
wrote on 15 Oct 2014, 15:58 last edited by
"video lag"? Your project is compiled in "DEBUG mode"?
Try compile in RELEASE.
-
wrote on 16 Oct 2014, 02:52 last edited by
Hi Guilherme, same in RELEASE mode.
I think it's a codec problem, it's a H.264 video. If you use CPU to decode, it may be not that efficient, and it'll drop some frames, to cause video lag.
That's why I want to use GPU to decode. -
wrote on 16 Oct 2014, 16:51 last edited by
I believe the "QT" use the defined "codecs" of your operating system, you may not be the question you set the "QT" but set the "CODEC" software installed on your machine, so even if you redistribute your project, the user will be required to configure the "codec" manually.
In other words, perhaps the only way of doing this is as "GoogleChrome" does: it has the own "codec" that accompanies the browser.
Unfortunately I do not know how to use a "codec" in itself "QtWebKit" (I really wanted to know if this is possible).
Alternative (improved perfomance of "webView"):
If Windows: You use "openGL"? Tried enable "webGL"?Note: I do not know if it will work, but it's a try.
Try this:
@QWebSettings *settings = QWebSettings::globalSettings();settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);
settings->setAttribute(QWebSettings::WebGLEnabled, true);@Note: Maybe QT5.4 use Chromium, see codec details: http://www.chromium.org/audio-video :)
-
wrote on 17 Oct 2014, 02:53 last edited by
oh, I played the same video in VLC and in Chrome in the same machine, both of them works fine! The video are smooth. So, I think, maybe I could do something in QtWebView to make it work.
Hmmm.. still got video lag. Thank you, Guilherme!
Interesting! :D
Thanks, Guilherme~
-
wrote on 5 Dec 2014, 16:12 last edited by
Hi birdca,
Just a comment:
Note, VLC and Chrome no using native codecs, but QT use native codec installed in your machine.
-
wrote on 5 Dec 2014, 16:12 last edited by
Hi birdca,
Just a comment:
Note, VLC and Chrome no using native codecs, but QT use native codec installed in your machine.
-
wrote on 8 Dec 2014, 13:26 last edited by
Noted, thank you Guilherme~
-
wrote on 8 Dec 2014, 13:26 last edited by
Noted, thank you Guilherme~