我正在使用我的应用程序中的AVAsset,遇到了下一个问题。当我写这样的东西时:
AVAsset *audioAsset = [AVAsset assetWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Hello.mp3", [[NSBundle mainBundle] resourcePath]]]];它工作得很好。但是当我尝试从我的tmp目录中获取新录制的文件时,就像这样在app的沙箱中:
AVAsset *audioAsset2 = [AVAsset assetWithURL:[NSURL URLWithString:[NSTemporaryDirectory() stringByAppendingPathComponent:[@"speechRecord" stringByAppendingPathExtension:@"m4a"]]]];它也不能工作。即使我尝试将视频文件从沙箱添加到资源-结果也是相同的。我甚至尝试过使用AVURLAsset,但asset也总是空的。我需要它来混合两个音频文件之间,然后合并它与录制的视频。如果我可以在没有AVAssets的情况下做到这一点,而且还有另一种方法,如果你告诉我,我将不胜感激。或者可能有其他函数来实现这个功能呢?
发布于 2014-03-28 04:07:55
您可以使用URLWithString选择器为audioAsset2创建第二个URL。您的第一个资源已正确加载,因为您使用了fileURLWithPath选择器。
如果您想在给定的URL处加载文件,请始终使用fileURLWithPath选择器创建NSURL对象。
因此,只需尝试:
AVAsset *audioAsset2 = [AVAsset assetWithURL:[NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[@"speechRecord" stringByAppendingPathExtension:@"m4a"]]]];https://stackoverflow.com/questions/21206643
复制相似问题