Creating AVAsset with HTTP NSURL

I am trying to combine two NSURLsthat contain links to videos. One URL points to AWS video, and the other points to locally stored video. My export code works because I tried it with two local videos, but whenever I try to combine 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 AVAssets:

AVAsset *firstAsset = [AVAsset assetWithURL:awsURL];

Do I need to AVAssetExportSessionuse local URLs?

+3
source share
3 answers

I saved the online address 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]
+3
source

@MichaelScaria, , , 3 . , AVAssets URL- URL-

+ (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;
}
+4

, AVURLAsset ? :

AVURLAsset - AVAsset - NSURL, , ( HTTP ), QuickTime, MP3 . , , AVComposition .

0

All Articles