m3u8文件AVAssetImageGenerator错误 [英] m3u8 file AVAssetImageGenerator error

查看:164
本文介绍了m3u8文件AVAssetImageGenerator错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AVPlayer播放.m3u8文件. 使用AVAssetImageGenerator通过以下代码从其中提取图像:

I am using AVPlayer to play .m3u8 file. Using AVAssetImageGenerator to extract image out of it using following code :

AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:mp.contentURL options:nil];
AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];
generate1.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1, 2);
CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:&err];
img = [[UIImage alloc] initWithCGImage:oneRef];

它总是给我错误:

错误域= AVFoundationErrorDomain代码= -11800操作无法完成" UserInfo = 0x7fb4e30cbfa0 {NSUnderlyingError = 0x7fb4e0e28530操作无法完成.(OSStatus错误-12782.)",NSLocalizedFailureReason =发生未知错误(-12782),NSLocalizedDescription =操作无法完成}

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x7fb4e30cbfa0 {NSUnderlyingError=0x7fb4e0e28530 "The operation couldn’t be completed. (OSStatus error -12782.)", NSLocalizedFailureReason=An unknown error occurred (-12782), NSLocalizedDescription=The operation could not be completed}

它适用于mp4,mov和所有主要视频扩展名URL,但不适用于m3u8.有什么想法吗?

It works for mp4,mov and all major video extensions URL but not for m3u8. Any idea??

推荐答案

您将无法使用AVAssetImageGenerator获取实时流的静止图像.相反,您可以使用

You won't be able to get still images for a live stream using AVAssetImageGenerator. Instead, you can use

AVPlayerItemVideoOutput

AVPlayerItemVideoOutput

使用AVPlayerItemVideoOutput,您可以使用以下方法获取给定.m3u8流在指定时间显示的图像:- (CVPixelBufferRef)copyPixelBufferForItemTime:(CMTime)itemTime itemTimeForDisplay:(CMTime *)outItemTimeForDisplay然后,您可以将返回的CVPixelBufferRef转换为图像(或其他图像)以进行显示

With AVPlayerItemVideoOutput you can get an image that is appropriate to display at a specified time for a given .m3u8 stream using the following method: - (CVPixelBufferRef)copyPixelBufferForItemTime:(CMTime)itemTime itemTimeForDisplay:(CMTime *)outItemTimeForDisplay Then, you can convert the returned CVPixelBufferRef into an image (or other) for display.

这篇关于m3u8文件AVAssetImageGenerator错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆