使用HTTP NSURL创buildAVAsset

我试图合并两个包含video引用的NSURLs 。 其中一个url指向AWS上的video,另一个指向本地存储的video。 我的导出代码工作,因为我已经试过了两个本地video,但每当我尝试合并HTTP URL和本地URL我得到此错误: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x155d2f20 {NSUnderlyingError=0x155b4f60 "The operation couldn't be completed. No such file or directory", NSLocalizedDescription=The requested URL was not found on this server.} Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x155d2f20 {NSUnderlyingError=0x155b4f60 "The operation couldn't be completed. No such file or directory", NSLocalizedDescription=The requested URL was not found on this server.}这是创buildAVAssets的代码:

 AVAsset *firstAsset = [AVAsset assetWithURL:awsURL]; 

AVAssetExportSession是否需要使用本地URL?

@MichaelScaria,非常感谢张贴你的想法,我在这个约3天。 下面是我的解决scheme,当我试图从本地url和远程url获取AVAssets

 + (AVAsset*)getAVAssetFromRemoteUrl:(NSURL*)url { if (!NSTemporaryDirectory()) { // no tmp dir for the app (need to create one) } NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES]; NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:@"temp"] URLByAppendingPathExtension:@"mp4"]; NSLog(@"fileURL: %@", [fileURL path]); NSData *urlData = [NSData dataWithContentsOfURL:url]; [urlData writeToURL:fileURL options:NSAtomicWrite error:nil]; AVAsset *asset = [AVAsset assetWithURL:fileURL]; return asset; } + (AVAsset*)getAVAssetFromLocalUrl:(NSURL*)url { AVURLAsset *asset = [AVAsset assetWithURL:url]; return asset; } 

我保存在线的url到一个临时目录,并使用临时的url来合并video,它的工作。

  NSData *urlData = [NSData dataWithContentsOfURL:initalURL]; [urlData writeToFile:path options:NSAtomicWrite error:nil] 

也许你需要使用AVURLAsset或其他的子类呢? 从文档:

您经常使用AVURLAsset(AVAsset的具体子类)实例化资产,NSURL指代视听媒体资源,如stream(包括HTTP实时stream),QuickTime电影文件,MP3文件和其他types的文件。 您还可以使用其他具体子类来实例化资产,这些子类以有用的方式扩展了视听媒体的基本模型,就像AVComposition用于临时编辑一样。