将MP4流式传输到iOS不能与JWPlayer和CloudFront一起使用

时间:2011-08-28 19:32:42

标签: ios amazon-s3 audio-streaming jwplayer amazon-cloudfront

尝试设置一个测试页面,该页面访问S3上托管的视频并使用CloudFront进行流式处理。我正在使用的播放器是JWPlayer,它也适用于iOS设备。

不幸的是,当我在iPhone上打开它时没有任何反应......我确信答案是显而易见的,但是在最后一个小时里它一直没能找到。这是代码(主要是来自http://aws.amazon.com/articles/4101?_encoding=UTF8&jiveRedirect=1的复制/粘贴):

<!--     THIS IS A BASIC HTML FILE TO PLAY MP4's USING JW PLAYER 
The following code is from longtailvideo.com's 'Setup Wizard', found at http://www.longtailvideo.com/support/jw-player-setup-wizard -->
<HTML>
<HEAD>
<TITLE>  
Streaming Video with JW Player
</TITLE>    
</HEAD>
<BODY>
<!-- Put a header above your video, if you like
-->
<H1>This is my header</H1>
<script type='text/javascript' src='http://s3.amazonaws.com/intrinseque-video/swfobject.js'></script>   
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
var so = new SWFObject('http://s3.amazonaws.com/intrinseque-video/player.swf','mpl','470','290','9');
     so.addParam('allowfullscreen','true');
     so.addParam('allowscriptaccess','always');
     so.addParam('wmode','opaque');
     so.addVariable('file','mp4:oceans-clip.ipad.mp4'); 
         so.addVariable('streamer','rtmp://s1m21pqfl8vlrl.cloudfront.net/cfx/st/'); 
     so.write('mediaspace');
</script>
</BODY>
</HTML>

<!--Common problems:
-   You cannot have any spaces in any of your URL's (including your 'rtmp://...'  URL)              (i.e.,  http:// thereisaspaceatthebeginninghere.xxx) 
-   Be sure you are calling the correctly numbered version of the flowplayer objects/players (i.e. flowplayer-3.2.2.swf
-   You cannot have duplicates of 's3.amazonaws.com' or 'cloudfront.net' in the same address (i.e. (http://s3.amazonaws.com/s3.amazonaws.com/YOUR_BUCKET/player.swf)
-   There is a different naming protocol for mp4 vs flv files. For .mp4 files, YOU MUST write it as 'mp4:YOUR_VIDEO_FILE_WITHOUT_THE _MP4_SUFFIX'. For .flv files, you simply write the name of the file, 'YOUR_VIDEO_FILE_WITHOUT_THE_FLV_SUFFIX'.
-->

2 个答案:

答案 0 :(得分:1)

查看http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/49/using-cloudfront

您需要添加以下内容:

     modes: [{
        type: "flash",
        src: "/assets/player.swf"
    },{
        type: "html5"
        config: {
            file: "http://dXXXXXXXXXXXX.cloudfront.net/example.mp4"
            provider: "video"
        }
    }],

代码,以便正确处理flash和html5。

答案 1 :(得分:0)

实际上,并非所有mp4文件都是平等的。使用奇怪的编码器/编解码器转换的有时不适用于IOS。我有一个案例,handbreak编码的mp4没有播放,而ffmpeg编码相同的视频流完美。

我从未明白究竟是什么区别。也许你要把视频元数据放在文件中的地方。