对于在HTML5中流式传输视频感到困惑 [英] Confused about streaming video in HTML5

查看:195
本文介绍了对于在HTML5中流式传输视频感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Amazon Cloudfront发行版中播放HTML5视频的最佳方式是什么?

What is the best way to play HTML5 video istantly from an Amazon Cloudfront distribution?

我已经对这个问题进行了大量的研究,似乎无法找到最好的方法。

I've done lots of research on the subject, and can't seem to work out the best way of doing it.

我目前正在使用popcorn.js,并尝试过使用video.js。视频正在运行,它不是直接在所有浏览器上播放。在IE中,它似乎首先下载整个文件。

I'm currently using popcorn.js, and have tried with video.js as well. Video is working, it's just not playing straight away on all browsers. In IE it seems to download the whole file first.

目前在Amazon Cloudfront发行版上使用MP4的HTML5视频最简单的解决方案是什么?

What's the simplest solution for HTML5 video using MP4s on an Amazon Cloudfront distribution at the moment?

推荐答案

如果您正在提供mp4,那么立即可能总会有一些延迟 - 客户端需要下载足够的视频在没有缓冲的情况下玩游戏(CloudFront等会帮助他们更加靠近用户)

If you are delivering an mp4 then "instantly" may always have some delay - the client needs to download enough of the video to play without buffering (CloudFront etc will help as they'll cache closer to the user)

您需要确保优化mp4文件以获得最佳交付效果。你需要玩一些设置,但我建议确保MOOV元素位于文件的开头,以帮助浏览器快速获取足够的元数据。

You will want to ensure that your mp4 file is optimized for best delivery... you'll need to play around with some of the settings but I would recommend making sure the MOOV element is at the start of the file to help the browser get enough metadata quickly.

我使用ffmpeg优化内容,通常是这些内容

I use ffmpeg to optimize content, usually something along these lines

./ffmpeg -y -i SourceFile.mp4 -s 1280x720 -c:v libx264 -b 3M -strict -2 -movflags faststart DestFile.mp4

you将要使用帧大小( -s 参数)和目标比特率( -b )来获取适合您所需速度的尺寸和质量的平衡。

you will want to play with the frame size (-s parameter) and the target bitrate (-b) to get the right balance of size and quality for the speed you need.

ha看一下为html 5准备mp4文件回答稍微长一点

have a look at preparing mp4 file for html 5 for a slightly longer answer as well

这篇关于对于在HTML5中流式传输视频感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆