开发者

HTML5 video, prefered codecs and indirect delivery

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" />开发者_C百科

</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


Is there a way to mark a format as 'preferred format'?

List them in order of preference. You have ogg first, so it is taken as preferred.

<video id="currentVideo" controls width=640>
<source type='video/mp4; codecs="avc1.64001E, mp4a.40.2"' src="http://mysite/2.mp4" />
<source type='video/ogg; codecs="theora, vorbis"' src="http://mysite/1.ogv" />
</video>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜