【问题标题】:Streaming Video - jwplayer, amazon s3 and cloudfront流媒体视频 - jwplayer、amazon s3 和 cloudfront
【发布时间】:2012-12-12 23:25:57
【问题描述】:

我在亚马逊的 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 错误。可能出了什么问题?

【问题讨论】:

    标签: amazon-s3 jwplayer amazon-cloudfront


    【解决方案1】:

    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

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

    【讨论】:

      【解决方案2】:

      我认为你必须将文件字符串值作为 bucketname/video.mp4 否则一切看起来都很好。

      【讨论】:

        【解决方案3】:

        不,这是不正确的,因为他使用的是 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/

        我希望这会有所帮助?

        【讨论】:

        • 由于某种原因,从 localhost 播放它不起作用。如果我将 HTML 部署到 S3 中的另一个存储桶并从那里将其加载到浏览器中,则视频播放效果很好(加载速度非常快!)。也许,'localhost' 有一些限制?
        【解决方案4】:

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

        【讨论】:

          【解决方案5】:

          从 'localhost' 以外的服务器加载 HTML 页面是可行的。

          【讨论】:

          • 这是对您自己问题的弱回答。您想在哪里获得徽章或其他东西?
          猜你喜欢
          • 2011-03-31
          • 2012-05-01
          • 1970-01-01
          • 2015-05-17
          • 2011-06-11
          • 2015-12-21
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多