HTML5 视频、首选编解码器和间接交付
我目前正在尝试构建一个 html5 视频页面,限制对视频的访问。因此,我想将视频从网络根目录中取出,并使用某种脚本检查用户帐户并传送视频。
如果我将 .ogv (theora) 和 .mp4 (h264) 文件放入 webroot 并使用带有多个源标签的视频标签,它们可以在所有测试的浏览器上运行:Firefox (ogg)、Chrome (ogg)、IE9 (mp4) )、Safari (mp4)、Opera (ogg)
<源类型='video/ogg; codecs="theora, vorbis"' src="http://mysite/1.ogv" />
<源类型='video/mp4; codecs="avc1.64001E, mp4a.40.2"' src="http://mysite/2.mp4" />
现在出现的第一个问题是:为什么 chrome 使用 ogg 格式?它在 mp4 视频的时间轴上清理速度要快得多,并且它确实支持 mp4 视频...有没有办法将格式标记为“首选格式”?
现在,如果我将文件从我的 webroot 中取出并使用像这样的 php 脚本来传送它们:
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); }
它应该输出文件,包括对 http 范围查询的支持。
HTML:
<源类型='video/ogg; codecs="theora, vorbis"' src="http://mysite/download.php/1.ogv" />
<源类型='video/mp4; codecs="avc1.64001E, mp4a.40.2"' src="http://mysite/download.php/2.mp4" />
Opera 无法再确定视频的播放长度,更糟糕的是:google chrome(及其免费克隆 Iron)挂起(mac 和 windows)- chrome 本身仍在运行,但加载站点的选项卡已锁定
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按优先顺序列出它们。你先有ogg,所以优先考虑。
List them in order of preference. You have ogg first, so it is taken as preferred.