gpt4 book ai didi

ios - m3u8 文件 AVAssetImageGenerator 错误

转载 作者:技术小花猫 更新时间:2023-10-29 10:09:21 27 4
gpt4 key购买 nike

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

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];

它总是给我错误:

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。有什么想法吗??

最佳答案

您的问题是意料之中的。 .m3u8 文件不是实际的 Assets 文件,而是更类似于播放列表。它们用于 HTTP Live Streaming,并根据可用带宽为“Segments”提供位置。

这里是一个 .m3u8 文件的例子 (Apple's sample .m3u8 file)

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=200000
gear1/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=311111
gear2/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=484444
gear3/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=737777
gear4/prog_index.m3u8

不幸的是,您无法创建 AVAsset 或 AVURLAsset 来表示 HTTP 直播流中的媒体。引用:Apple's reference example of Asset Loading/playing

关于ios - m3u8 文件 AVAssetImageGenerator 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32112205/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com