I'm trying to merge two NSURLs
that contain video references. One of the urls point to a video on AWS and the other points to a video that is stored locally. My exporting code works because I've tried it with two local videos, but whenever I try merge the HTTP url and the local url I get this error: 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.}
This is the code to create the AVAssets:
AVAsset *firstAsset = [AVAsset assetWithURL:awsURL];
Does AVAssetExportSession
require local urls to be used?
@MichaelScaria, many thanks for posting what you figured out, i was on this for about 3 days. below is my solution in full when i was trying to get AVAssets from both local urls and remote urls
+ (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;
}
I saved the online url to a temporary directory and used the temporary url to merge the video and it worked.
NSData *urlData = [NSData dataWithContentsOfURL:initalURL];
[urlData writeToFile:path options:NSAtomicWrite error:nil]
Maybe you need to use AVURLAsset
or other subclasses instead? From the docs:
You often instantiate an asset using AVURLAsset—a concrete subclass of AVAsset—with NSURLs that refer to audiovisual media resources, such as streams (including HTTP live streams), QuickTime movie files, MP3 files, and files of other types. You can also instantiate an asset using other concrete subclasses that extend the basic model for audiovisual media in useful ways, as AVComposition does for temporal editing.