QtWebKit + Video = :-)

Kubuntu 10.10 is likely to come with a QtWebKit using browser (currently Rekonq is default) and QtWebKit allegedly does some HTML 5 magic. Most importantly from my POV audio and video playback without flash or anything.

So the other day I was annoyed over YouTube making Rekonq crash because of dearest Adobe Flash, which made me look into the experimental HTML 5 support YouTube provides. The shocking news: it does not work (what a surprise). Fortunately QtWebKit is using Phonon, the magic multimedia system of Qt and KDE, so I tried with the VLC backend for Phonon and it worked even less than the default xine backend did… HTML 5 support, yeah, sure 😛

Jonathan Riddell however suggested that both audio and video work somewhat well in the GStreamer backend, which made me realize that there is hope after all. I moved out to fix the VLC backend. A task that sounds a lot easier than it really was, because QtWebKit is a very large beast and without having any clue about “web engine/rendering stuff things” it is very difficult to find one’s way. But after running QtWebKit for a day or two through gdb and breaking at all sorts of functions I knew the follwing:

a) The VLC backend is at an early point in a wrong playback state which makes QtWebKit fall on its face (which affects both audio and video).
b) Something horrible is going on that makes videos not work.

After some poking and whining in the VLC backend I finally got audio working by ensuring that a call to Phonon’s pause() function would actually switch to a pause state and allow resume at next call to pause (which is archived by a somewhat nasty hack that needs to be fixed by some additional foo in libVLC). Awesome! At this point video also had sound, but no moving pictures. After some more research it turned out that QtWebKit explicitly deactivates the way the VLC backend would usually show a video and instead requires the backend to manually paint the images in a given area (so ultimately control about playback timing is done by QtWebKit and not the backend). Luck was in my favor, as only recently libVLC grew easy to use support for hooking into playback and getting frame by frame.

Having implemented this magical way of making the pictures move, we now have video and audio support \o/

[Flash Version]

Feel free to test the Git version from gitorious (requires VLC >= 1.1.1).

PS: A testing page for OGA, OGV and WEBM is available here.

PPS: YouTube is still not working, most likely because it is passing some weird URL which makes VLC run into HTTP 403 errors. Dear YouTube, do you not like us? 😦


12 thoughts on “QtWebKit + Video = :-)

  1. apachelog.wordpress.com isn’t serving the .webm video file with the correct mime type. It should be “video/webm”, but it sends it as Content-Type: text/html; charset=iso-8859-1 , which is I think why it doesn’t work in Firefox 4 betas.

    Thanks for advancing Kubuntu.

  2. Hi,

    I am developing a phonon+ruby powered mediaplayer for kde.

    By know only youtube is supported. I have had a lot of troubles getting youtube urls which finaly could be played via phonon. For me the trick was to disable the use of cookies in KIO. Otherwise I also got 403 errors as far as I can remember.

    Without this line it wasn’t working:

    I hope you find an equal problem in your code and can solve this the same way.


  3. Most likely because of lack of cookies in the request for the video. We had the same issue in WebKitGTK+, and slomo fixed it by first feeding GStreamer’s souphttpsrc element with the cookies, and after that it got fixed even more by writing a custom GStreamer source element that uses WebCore’s network machinery to do the actual video download, ensuring proper cookie sending.

  4. qtwebkit browsers tend to crash like it’s going out of style. Is there any chance that will be worked out by the time 10.10 rolls around?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s