流媒体视频 - jwplayer,亚马逊S3和CloudFront

6

我在亚马逊上有一个流分发,位于s6b99lczhnef6.cloudfront.net。源是S3中的一个存储桶。存储桶里有一个名为video.mp4的视频,它是公开的。 我正在尝试使用jwplayer测试流式传输此视频,以下是代码:

<html>
<head>
    <script type="text/javascript" src="jwplayer/jwplayer.js"></script>
</head>
<body>
    <div id="container">Loading the player ...</div>
    <script type="text/javascript">
    jwplayer("container").setup({
        flashplayer: "jwplayer/player.swf",
        file: "video.mp4",
        height: 270,
        provider: "rtmp",
        streamer: "rtmp://s6b99lczhnef6.cloudfront.net/cfx/st",
        width: 480
    });
    </script>
</body> 
</html>

视频无法播放。没有JS错误。可能出了什么问题?
5个回答

2
Amazon文档适用于JW Player 5.9版本,而JW Player的文档在使用CloudFront流媒体方面相对较少。正如此处简要解释的那样,在JW Player 6中,指定流媒体源已经发生了变化。以下是指定流媒体源的新方法:
<div id='mediaplayer'>This text will be replaced</div>
<script type="text/javascript">
   jwplayer('mediaplayer').setup({
      'id': 'playerID',
      'width': '720',
      'height': '480',
      'file': 'rtmp://s1cxpk7od1m10r.cloudfront.net/cfx/st/your_streaming_file.mp4',
      'primary':'flash',
      'autostart' : 'true',
   });
</script>

如果您的流在文件夹中,使用上面的文件引用可能会出现一些问题。我不确定为什么rtmp://s1cxpk7od1m10r.cloudfront.net/cfx/st/folder/your_streaming_file.mp4对我无效(我认为这与URL编码有关),但是当访问位于文件夹中的流资源时,使用此参数file可以正常工作。
rtmp://s1cxpk7od1m10r.cloudfront.net/cfx/st/mp4:folder/your_streaming_file.mp4

如果您想测试连接字符串并获得一些调试输出,请查看此流式诊断工具
在嵌入代码中,您不需要指定存储桶名称。

1

我认为您需要将文件字符串值设置为bucketname/video.mp4,否则一切都很好。


0
不需要提供存储桶名称。CloudFront分发已经指向一个存储桶。

0
不,那是不正确的,因为他正在使用CloudFront。 我看到引号的使用不一致。试试这个:
<div id="container">Loading the player ...</div>
<script type="text/javascript">
jwplayer("container").setup({
    'flashplayer': 'jwplayer/player.swf',
    'file': 'video.mp4',
    'height': '270',
    'provider': 'rtmp',
    'streamer': 'rtmp://s6b99lczhnef6.cloudfront.net/cfx/st',
    'width': '480'
});
</script>

这里有一篇教程,详细解释了格式和选项。 http://www.miracletutorials.com/embed-streaming-video-audio-with-html5-fallback/

如果这不起作用,可能是您的视频没有针对流媒体进行优化。 请尝试使用此教程转换您的视频: http://www.miracletutorials.com/how-to-encode-video-for-web-iphone-ipad-ipod/

希望这可以帮到您?


由于某种原因,从本地主机播放它不起作用。如果我将HTML部署到S3中的另一个存储桶中,并从那里在浏览器中加载它,则视频播放得很好(加载速度相当快!)。也许,“localhost”有一些限制? - septerr

-4

从除了“localhost”以外的服务器加载HTML页面是可行的。


这是一个对你自己问题的弱答案。你是想要获得徽章吗? - Matthew Purdon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接