流媒体视频 - jwplayer,亚马逊s3和cloudfront

时间:2012-06-10 18:04:19

标签: amazon-s3 jwplayer amazon-cloudfront

我在亚马逊的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 个答案:

答案 0 :(得分:2)

amazon documentation对JW Player 5.9有效,而JW Player的文档在使用CloudFront流时相当稀少。 As briefly explained here,使用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

如果要测试连接字符串并获得一些调试输出checkout this streaming diagnostic tool

您无需在嵌入代码中的任何位置指定存储桶名称。

答案 1 :(得分:1)

我认为你必须提供文件字符串值作为bucketname / video.mp4否则一切似乎都很好。

答案 2 :(得分: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/

我希望这有帮助吗?

答案 3 :(得分:0)

不,您不需要提供存储桶名称。云端分发已指向存储桶。

答案 4 :(得分:-4)

从“localhost”以外的服务器加载HTML页面。