简体   繁体   English

AVPlayer和AWS服务流

[英]AVPlayer and AWS Services Streaming

I'm attempting to stream videos from AWS S3 bucket. 我正在尝试从AWS S3存储桶流式传输视频。 I uploaded several fils with the "make for everyone" permissions. 我上传了几份具有“让每个人都拥有”权限的文件。

I have also created a CloudFront distribution (I just chose my bucket and let all others choices by default). 我还创建了一个CloudFront发行版(我只是选择了我的存储桶,默认情况下让所有其他选项都选择了)。 In a web browser I can download file / read with the adress http://distribution.cloudfront.net/movie1.mov 在网络浏览器中,我可以下载文件/通过地址http://distribution.cloudfront.net/movie1.mov阅读

In my project I have initiated an AVPlayer which takes path from a tableview (like an itune but for movie). 在我的项目中,我启动了一个AVPlayer,该AVPlayer从表视图获取路径(就像iTunes一样,但用于电影)。 The file for each row is the same as tested in my web browser: http://distribution.cloudfront.net/movie1.mov for row1 distribution.cloudfront.net/movie2.mov for row2 ... 每行的文件与在我的网络浏览器中测试的文件相同: http : //distribution.cloudfront.net/movie1.mov for row1 distribution.cloudfront.net/movie2.mov for row2 ...

The player takes well the path and start playing but it freeze always at the same time. 玩家沿路径前进并开始游戏,但总是同时冻结。 I have to pause or advance/back to continue the video. 我必须暂停或前进/后退才能继续播放视频。

SO it seems to be a buffer problem. 因此,这似乎是一个缓冲问题。

I would like to know if I use well AWS Cloud Front and how I can resolve the buffer problem. 我想知道我是否使用得当,以及如何解决缓冲区问题。

I didn't find any good tutorials or answers about this. 我没有找到任何关于此的好的教程或答案。

Thank you for your help. 谢谢您的帮助。

Regards 问候

did you set the Geographic restrictions on cloudfront so that it uses the servers in the area closest to you? 您是否在Cloudfront上设置了地理限制,以便它使用离您最近的区域中的服务器?

I meant between web and RMTP in my first comment. 我的第一句话是在Web和RMTP之间。 You want web so that is correct. 您需要网络,以便正确。

Now that it is restricted to France, test your videos again and see if their performance is better. 现在仅限法国使用,请再次测试您的视频,看看它们的效果是否更好。

You will want to allow other regions as your usage expands. 随着使用范围的扩大,您将希望允许其他区域。 Remember different regions have DIFFERENT PRICES for cloudfront. 请记住,不同地区的Cloudfront价格不同。 EU and USA are the same but the other regions can be twice as expensive or more . 欧盟和美国一样,但是其他地区的价格可能是其两倍甚至更高。

http://aws.amazon.com/cloudfront/pricing/ http://aws.amazon.com/cloudfront/pricing/

AVPlayer can stall while streaming long videos. 流长视频时,AVPlayer可能会停顿。

You will need to register observers for the keys playbackBufferEmpty and playbackLikelyToKeepUp 您将需要为键playbackBufferEmpty和playbackLikelyToKeepUp注册观察者。

[playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];

Then on, 然后,

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
                        change:(NSDictionary *)change context:(void *)context {
    if (!player)  {
        return;
    }

    else if (object == playerItem && [keyPath isEqualToString:@"playbackBufferEmpty"])  {
        if (playerItem.playbackBufferEmpty) {
            //Other relevant code here, like adding spinner
        }
    }

    else if (object == playerItem && [keyPath isEqualToString:@"playbackLikelyToKeepUp"])  {
        if (playerItem.playbackLikelyToKeepUp)  {
            [player play];
            //Other relevant code here, like removing spinner
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM