[QWebView] HTML5 video with Hardware Decoding



  • 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!



  • Hi,
    i'm not sure but try this:
    @view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);@



  • Thanks Vovasty, but after adding this, the video is still lag...



  • "video lag"? Your project is compiled in "DEBUG mode"?

    Try compile in RELEASE.



  • 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.



  • 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 :)



  • 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~



  • Hi birdca,

    Just a comment:

    Note, VLC and Chrome no using native codecs, but QT use native codec installed in your machine.



  • Hi birdca,

    Just a comment:

    Note, VLC and Chrome no using native codecs, but QT use native codec installed in your machine.



  • Noted, thank you Guilherme~



  • Noted, thank you Guilherme~


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.