Note that there are some explanatory texts on larger screens.

plurals
  1. POCaching with AVPlayer and AVAssetExportSession
    primarykey
    data
    text
    <p>I would like to cache progressive-download videos using AVPlayer. How can I save an AVPlayer's item to disk? I'm trying to use AVAssetExportSession on the player's currentItem (which is fully loaded). This code is giving me "<em>AVAssetExportSessionStatusFailed (The operation could not be completed)</em>" :</p> <pre><code> AVAsset *mediaAsset = self.player.currentItem.asset; AVAssetExportSession *es = [[AVAssetExportSession alloc] initWithAsset:mediaAsset presetName:AVAssetExportPresetLowQuality]; NSString *outPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"out.mp4"]; NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager removeItemAtPath:outPath error:NULL]; es.outputFileType = @"com.apple.quicktime-movie"; es.outputURL = [[[NSURL alloc] initFileURLWithPath:outPath] autorelease]; NSLog(@"exporting to %@",outPath); [es exportAsynchronouslyWithCompletionHandler:^{ NSString *status = @""; if( es.status == AVAssetExportSessionStatusUnknown ) status = @"AVAssetExportSessionStatusUnknown"; else if( es.status == AVAssetExportSessionStatusWaiting ) status = @"AVAssetExportSessionStatusWaiting"; else if( es.status == AVAssetExportSessionStatusExporting ) status = @"AVAssetExportSessionStatusExporting"; else if( es.status == AVAssetExportSessionStatusCompleted ) status = @"AVAssetExportSessionStatusCompleted"; else if( es.status == AVAssetExportSessionStatusFailed ) status = @"AVAssetExportSessionStatusFailed"; else if( es.status == AVAssetExportSessionStatusCancelled ) status = @"AVAssetExportSessionStatusCancelled"; NSLog(@"done exporting to %@ status %d = %@ (%@)",outPath,es.status, status,[[es error] localizedDescription]); }]; </code></pre> <p>How can I export successfully? I'm looking into copying mediaAsset into an AVMutableComposition, but haven't had much luck with that either.</p> <p>Thanks!</p> <p>PS: Here are some questions from people trying to accomplish the same thing (but with MPMoviePlayerController):</p> <ul> <li><p><a href="https://stackoverflow.com/questions/3338237/cache-progressive-downloaded-content-in-mpmovieplayercontroller">Cache Progressive downloaded content in MPMoviePlayerController</a></p></li> <li><p><a href="https://stackoverflow.com/questions/907230/simultaneously-stream-and-save-a-video">Simultaneously stream and save a video?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/934303/caching-videos-to-disk-after-successful-preload-by-mpmovieplayercontroller">Caching videos to disk after successful preload by MPMoviePlayerController</a></p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload