gpt4 book ai didi

iphone - AVURLAsset 和 AVAssetImageGenerator 返回空图像

转载 作者:行者123 更新时间:2023-12-03 19:32:01 26 4
gpt4 key购买 nike

我正在尝试从 iPhone 相机捕获的 .mov 文件中获取缩略图。我目前已将电影保存在应用程序的文档部分中。当我调用 [ Assets 持续时间] 时,它返回一个空对象。此外,当我尝试调用 copyCGImageAtTime:actualtime:error 方法时,它也返回一个 null 对象。我花了更少的时间试图解决这个问题。我尝试将代码移动到应用程序的另一个主要部分,看看是否可以让它工作。我也尝试在模拟器上运行它,但没有成功。这是代码:

NSString* destinationPath = [NSString stringWithFormat:@"%@/aaa/aaa.mov", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL URLWithString:destinationPath] options:nil];
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
gen.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(0.0, 600);
NSError *error2 = nil;
CMTime actualTime;

CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error2];
UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
CGImageRelease(image);

我还确认该文件夹下确实存在该电影。任何帮助将不胜感激。谢谢:)

--编辑--

忘记提及 copyCGImageAtTime 的错误是 AVUnknown 错误。

--编辑2--发现问题了。我没有在 url 开头包含 file://。现在可以了。

最佳答案

发现问题了。我没有在网址开头包含 file:// 。现在可以了。

关于iphone - AVURLAsset 和 AVAssetImageGenerator 返回空图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7945691/

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