i am currently trying to build a html5 video page with restrictive access to the videos. Therefor i want to put the videos out of web root and have some kind of script check the user account and deliver the video.
If i put a .ogv (theora) and a .mp4 (h264) file just into webroot and use a video tag with multiple source tags, they work on all tested browsers: Firefox (ogg), Chrome (ogg), IE9 (mp4), Safari (mp4), Opera (ogg)
<video id="currentVideo" controls width=640>
<source type='video/ogg; codecs="theora, vorbis"' src="http://mysite/1.ogv" />
<source type='video/mp4; codecs="avc1.64001E, mp4a.40.2"' src="http://mysite/2.mp4" />
</video>
Now the first question that comes up is: Why is chrome using the ogg format? It scrubs much faster through the timeline with mp4 videos and it does support mp4 videos... Is there a way to mark a format as 'preferred format'?
Now if i put the files out of my webroot and use a php script like this to deliver them:
download.php:
$path=explode('/',$_SERVER['PATH_INFO']); if (sizeof($path)>1) { $inf=explode('.',$path[1]); $id=intval($inf[0]); $type=$inf[1]; $ctype=''; if ($type=='ogv') { $ctype='video/ogg'; } elseif ($type=='mp4') { $ctype='video/mp4'; } $fname=sprintf('/var/outsidewebroot/videos/test.%s',$type); http_send_content_type($ctype); http_throttle(0.1); http_send_file($fname); }
which should put out the file including support for http range queries.
HTML:
<video id="currentVideo" controls width=640>
<source type='video/ogg; codecs="theora, vorbis"' src="http://mysite/download.php/1.ogv" />
<source type='video/mp4; codecs="avc1.64001E, mp4a.40.2"' src="http://mysite/download.php/2.mp4" />
</video>
Opera is not able anymore to determine playing length of the video, and even worse: google chrome (and its free clone iron) hang (mac and windows) - chrome itself remains running, but the tab loading the site is locked
Accept
request header's quality factors might be useful for this. It's supposed to allow the client to prioritize different media types. However, I don't know if there's any way to manually tell the browser to set this field. It might just be something that only browser plugins have access to. w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 – Lèse majesté