3 Mar 2009
90476
hits

Setting up a HTML5 on-line video site

Today a friend asked me how to set up an on-line video site. It seems that he read my previous post on the new Audio / Video Streaming plug-in shipped with the latest version of Cherokee, and he felt like it was time to upgrade his web server and site content.

I proposed him to support both the HTML5 and Flash methods for playing the videos. This means, to use the new tag <video>, and only relay on Flash whenever the browser does not support HTML5 embedded videos.

We found a problem on the very first test we did, though. Even if the two web browser that we tested did support <video>, we didn't find a common video format supported by both of them. The test showed Firefox 3.1 supporting Theora and failing to play H264/AAC, and Safari 4 playing H264/AAC but not being able to reproduce Theora.

The solution? Convert the video to the two formats and make both available. If you have done it previously, I bet you know that video converting is one of those time consuming tasks that can easily get messy. Of course, after converting a few videos we found a problem with one of them. Long story short: after some research the solution was to compile FFMpeg/trunk with some other libraries:

FFmpeg version SVN-r17752:
--enable-shared --disable-mmx --enable-libtheora --enable-libvorbis
--enable-libx264 --enable-libxvid --enable-libmp3lame --enable-libfaad
--enable-libfaac --enable-gpl

Here is a very simple example of how you can use the <video> tag for the modern clients, and Flash as second and more secure option. Do not hesitate to read the example page source to check what the syntax is. Beside the Theora/H264 issue, supporting <video> + Flash is really straight forward.

<video controls>
<source src="test.mp4">
<source src="test.ogv" type="video/ogg; codecs=theora,vorbis">
<a href="test.mp4" id="player"></a>
<script>
$f("player", "flowplayer-3.0.5.swf");
</script>
</video>

By the way, the video streaming is served by Cherokee's Audio / Video Streaming plug-in, so independently of whether <video>  is used, the connection bandwidth will be limited to the video bitrate. Doesn't it look interesting for optimizing your server bandwidth usage? It allows the server to handle more concurrent users, at the same time that it helps to save the bandwidth of the videos that are not completely watched.

Comments

Remm on Tue Mar 3 22:16:30 2009
1102


I would like to understand why you keep on spamming planet gnome with this irrelevant stuff.
antxon on Tue Mar 3 22:18:28 2009
1103


@remm ok, not very related to GNOME stuff but I like alo's posts...
Stoffe on Tue Mar 3 23:11:52 2009
1104


*sigh* Apple... they're every bit as bad as Microsoft. And I for one welcome this post on planet GNOME.
Jonas on Wed Mar 4 00:15:14 2009
1105


What I don't understand about this "bandwidth will be limited to the video bitrate" thing, is how you seem to completely disregard client-side caching (unless you're not giving us the entire story). It sounds like a recipe for playback hiccups at even the slightest bandwidth issues on the client.
David Moreno on Wed Mar 4 01:41:20 2009
1106


@Remm: I would like you to shove relevant stuff up your ass. Great post, Alo!
emmanuel on Wed Mar 4 07:56:42 2009
1107


this is very interesting for free software in general. i was afraid of this kind of issues of safari not supporting theora. this is a big issue for the video tag in general, because for big big websites (think youtube) keep two copies of each video is way overkill... i wonder if chrome will ship theora. I guess they won't :-(
pete on Wed Mar 4 19:00:26 2009
1108


> because for big big websites (think youtube) keep two copies of > each video is way overkill... Youtube does already keep at least two copies (flv, mp4) of each video.
Braydon Fuller on Fri Mar 6 07:09:22 2009
1111


You can also use Cortado as a fallback player and only have the Ogg video file.
Hans on Fri Jun 5 13:22:06 2009
1154


Does Cherokee support OGG Theora video seeking? If not, when will this be available?
Alex on Wed Jul 1 13:19:36 2009
1183


Nice article. Keep it up!
Lyssa on Sun May 2 18:58:44 2010
1309


This is great! It helped me a lot!
Sonny on Sun Jul 4 08:49:04 2010
1402


I want to start a site like Youtube Peoples can upload video but very important video need to be read able by iphone ipad What do i need

Leave a comment

Name:

Comment:


Loading PhotoLog..


Search

 

Twitter


Facebook

Alvaro Lopez Ortega's Profile
Alvaro Lopez Ortega's Facebook Profile