3

我正在尝试合并两个NSURLs包含视频参考的内容。其中一个 url 指向 AWS 上的视频,另一个指向本地存储的视频。我的导出代码有效,因为我已经尝试使用两个本地视频,但是每当我尝试合并 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.} 这是创建 AVAssets 的代码:

AVAsset *firstAsset = [AVAsset assetWithURL:awsURL];

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

4

3 回答 3

6

@MichaelScaria,非常感谢您发布您的发现,我在这上面呆了大约 3 天。以下是我尝试从本地 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;
}
于 2014-08-28T06:18:02.720 回答
3

我将在线 url 保存到一个临时目录并使用临时 url 合并视频并且它有效。

    NSData *urlData = [NSData dataWithContentsOfURL:initalURL];
    [urlData writeToFile:path options:NSAtomicWrite error:nil]
于 2013-08-10T02:28:12.410 回答
0

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

您经常使用 AVURLAsset(AVAsset 的具体子类)实例化资产,其中 NSURL 引用视听媒体资源,例如流(包括 HTTP 实时流)、QuickTime 电影文件、MP3 文件和其他类型的文件。您还可以使用其他具体子类来实例化资产,这些子类以有用的方式扩展视听媒体的基本模型,就像 AVComposition 对时间编辑所做的那样。

于 2013-08-09T10:45:02.123 回答