有没有办法在 .ogg 视频完全加载之前知道其文件大小?
我知道 ogg 视频和 mp4 视频之间的一个区别是 ogg 视频没有描述文件大小的元数据,因此当加载 ogg 视频时,控件无法显示文件完全加载之前的剩余时间。如果 ogg 视频长度超过几分钟,这可能会成为问题。有没有办法在请求页面时获取此文件大小?
(客户端开发人员,提出一个我认为有服务器端答案的问题。如果您能想出一种更具体的方法,我欢迎对此问题进行建议编辑。)
I know one difference between ogg video and mp4 video is that ogg video doesn't have metadata describing the file size, so when an ogg video is loaded, the controls can't show the time remaining until the file has fully loaded. This can be a problem if the ogg video is more than a few minutes long. Is there a way to get this filesize when the page is requested?
(Client-side developer, asking a question that I think has a server-side answer. I welcome suggested edits to this question, if you can think of a way to ask it more specifically.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,虽然不是最直接的,但你可以尝试一下。
首先,设置 .htaccess 以透明地抓取所有 .ogv 视频并使用 PHP 处理它们
。 .htaccess
ogv.php
HTML:
以下是该系统的工作原理。只需像平常一样链接 .ogv 视频,但 .htaccess 文件首先捕获请求并将其发送到 ogv.php。然后,PHP 文件会专门发送一个文件大小标头,以防服务器不自动发送。好吧,这仍然对你没有多大好处,对吧?那么,您可以对视频发出 Ajax 请求并从 HTTP 标头中提取文件大小。
希望这有帮助。
Well although not the most direct, you could try this.
First, set up a .htaccess to transparently grab all .ogv videos and process them with PHP
.htaccess
ogv.php
HTML:
So here's how this system works. Just link a .ogv video like normal but the .htaccess file captures the request first and sends it to ogv.php. The PHP file then specifically sends out a file size header in case the server doesn't automatically. Okay, that still doesn't do you a whole lot of good, right? Well, you can then make an Ajax request for the video and extract the filesize from the HTTP headers.
Hope this helps.