Cocoa: AVAsset from raw data (i.e. NSData)

I'd like to use AVFoundation to display a video on osx. I would like to initialize the movie from raw data at runtime. According to this document: https://developer.apple.com/library/mac/#technotes/tn2300/_index.html AVAsset is the equivalent of QTKit's QTMovie . QTMovie has the function movieWithData:error: to load the video from data, while i could not find anything similar in AVAsset . So, is it possible to do the same thing in AVFoundation at all?

Thank you


NSString *tempFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"tmp.mp3"];

NSFileManager *manager = [NSFileManager defaultManager];
[manager createFileAtPath:tempFilePath contents:mp3Data attributes:nil];

AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:tempFilePath] options:nil];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [manager removeItemAtPath:tempFilePath error:nil];
        });

I am afraid the unique possibility to initialize AVAsset instance from raw data is to save the data before as a file. AVAsset and its subclasses are using URLs only in their constructors.

链接地址: http://www.djcxy.com/p/64226.html

上一篇: 继承和ASP.NET Web API的JSON格式化程序

下一篇: 可可:原始数据的AVAsset(即NSData)