使用HTTP NSURL创建AVAsset

Mic*_*ria 3 iphone objective-c avfoundation ios

我正在尝试合并NSURLs包含视频引用的两个.其中一个网址指向AWS上的视频,另一个指向本地存储的视频.我的导出代码有效,因为我已尝试使用两个本地视频,但每当我尝试合并HTTP网址和本地网址时,我都会收到此错误: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.} 这是创建AVAssets的代码:

AVAsset *firstAsset = [AVAsset assetWithURL:awsURL];
Run Code Online (Sandbox Code Playgroud)

是否AVAssetExportSession需要使用本地网址?

gre*_*use 6

@MichaelScaria,非常感谢您发布了您想到的内容,我在此约3天.当我试图从本地网址和远程网址获取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;
}
Run Code Online (Sandbox Code Playgroud)