我正在尝试合并两个包含视频引用的NSURLs。其中一个urls指向AWS上的视频,另一个指向本地存储的视频。我的导出代码可以工作,因为我尝试过使用两个本地视频,但是每当我尝试合并HTTP和本地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是否需要使用本地urls?
发布于 2013-08-10 02:28:12
我将在线url保存到一个临时目录中,并使用这个临时url合并视频,它工作了。
NSData *urlData = [NSData dataWithContentsOfURL:initalURL];
[urlData writeToFile:path options:NSAtomicWrite error:nil]发布于 2014-08-28 06:18:02
@MichaelScaria,非常感谢你发布的信息,我在上面写了大约3天。下面是我在尝试从本地urls和远程urls获取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;
}发布于 2013-08-09 10:45:02
也许您需要使用AVURLAsset或其他子类来代替?从医生那里:
您通常使用AVURLAsset(AVAsset的一个具体子类)实例化资产,使用引用视听媒体资源的NSURL,例如流(包括)、QuickTime电影文件、MP3文件和其他类型的文件。您还可以使用其他具体子类实例化资产,这些子类以有用的方式扩展了视听媒体的基本模型,就像AVComposition用于时态编辑一样。
https://stackoverflow.com/questions/18139203
复制相似问题