Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9019335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:45:07+00:00 2026-06-16T04:45:07+00:00

I have searched and read the docs, but I cannot seem to find a

  • 0

I have searched and read the docs, but I cannot seem to find a solution to this (seemingly-simple) issue I’ve run into. I have songs exporting working fine from the user’s iTunes library, and it downloads into the user’s documents folder with no issues every time, but videos just don’t seem to work.

I have it showing an MPMediaPickerController (allowsPickingMultipleItems = YES) to allow the user to select either videos or songs from their downloaded library. When done, here is the relavent code I’m using:

- (void)mediaPicker:(MPMediaPickerController*)mediaPicker didPickMediaItems:(MPMediaItemCollection*)mediaItemCollection {
    AVAssetExportSession *exportSession;

    for (MPMediaItem *item in mediaItemCollection.items) {
        NSURL *assetUrl = [item valueForProperty:MPMediaItemPropertyAssetURL];
        MPMediaType type = [[item valueForProperty:MPMediaItemPropertyMediaType] intValue];
        if (type >= MPMediaTypeMovie) {
            exportSession = [[AVAssetExportSession alloc] initWithAsset:[AVAsset assetWithURL:assetUrl] presetName:AVAssetExportPreset640x480];
            exportSession.outputFileType = AVFileTypeQuickTimeMovie;
            filePath = [title stringByAppendingString:@".mov"];
            exportSession.outputURL = [NSURL fileURLWithPath:[[NSFileManager documentDirectory] stringByAppendingPathComponent:filePath]];
        } // .. check for song-types here and set session up appropriately

        [exportSession exportAsynchronouslyWithCompletionHandler:^{
            // never gets into AVAssetExportSessionStatusCompleted here for videos 
        }
    }
}

The error I get every time is the following:

Error Domain=AVFoundationErrorDomain Code=-11820 "Cannot Complete Export" UserInfo=0x1e1a2180 {NSLocalizedRecoverySuggestion=Try exporting again., NSLocalizedDescription=Cannot Complete Export}

Not very helpful. 🙁 I feel like I may be potentially missing something obvious here. Am I going about this the correct way? Is it potentially a problem with me trying to “force” it to MOV-format? Or perhaps needing a different way of setting up the export session?

For reference, I’m using iOS 6.0.1 on my iPhone 5 for testing, with a baseSDK of 6.0. Thanks in advance for any guidance that can be offered on this!

Additional Info #1: something that’s odd. It seems to crash immediately with a “SIGTRAP” if I set the outputFileType to “AVFileTypeAppleM4V”.. I wanted to try M4V, because when I do a log output of the assetURL, I see something like: ipod-library://item/item.m4v?id=12345. Don’t know if that makes a difference or not, but odd that it just crashes like that if I try m4v format. Probably because it’s not in the supported filetypes list (see next info point).

Additional Info #2: The supported file types I get (from calling the “supportedFileTypes” method are: “com.apple.quicktime-movie” and “public.mpeg-4”. The “exportPresetsCompatibleWithAsset” include all of the video ones, including m4a, low/med/high quality, and the specific dimensions ones. I have tried EVERY combination of all these, such as AVFileTypeQuickTimeMovie and AVFileTypeMPEG4 for fileTypes, and all of the presets, including the low/med/high, and all of the dimension ones. It never fails that I get the “Cannot Complete Export” error.

Additional Info #3: I am also using a Deployment Target of 5.1. But yes, I have tried 6.0, and it gives the same error. 🙁

Additional Info #4: If needed to know, the movie I’m testing with is a “Pilot” TV show, one video, the first one I saw in iTunes that was free. So I downloaded it for use in this app.

Additional Info #5: Not sure if this is important, but the “hasProtectedContent” method returns YES for the AVAsset (and AVURLAsset if I convert). May not make a difference, but thought I’d throw it out there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:45:08+00:00Added an answer on June 16, 2026 at 4:45 am

    After trying to replicate the issue and doing some testing, I strongly suspect the protected content is an issue. Here’s why:

    I copied your code, and tested it on my iPod Touch (5th gen, iOS 6.0.1), though instead of coming from a media picker, I just let it loop through all the videos I have on the device (7 of them.) It worked great, and called the completion handler and made proper .mov files in the documents directory of the app sandbox. I moved the .mov files to my Mac and they all played.

    These video files had the hasProtectedContent as NO.

    So I placed a video file I got from the iTunes store, and confirmed it had the hasProtectedContent as YES. Interestingly, when I try to get the URL from MPMediaItemPropertyAssetURL, I get nil for the protected/iTunes obtained video.

    I strongly suspect the media protection is the problem.

    Here’s the variation of code that I used. I didn’t change your conversion code at all, just how the URLs are supplied:

    // select all the video files
    MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInteger:MPMediaTypeMovie] forProperty:MPMediaItemPropertyMediaType];
    
    MPMediaQuery *query = [[MPMediaQuery alloc] init];
    [query addFilterPredicate:predicate];
    
    NSArray *items = [query items];
    
    // now go through them all to export them
    
    NSString* title;
    NSURL * url;
    AVAssetExportSession *exportSession;
    NSString *storePath;
    AVAsset *theAsset;
    
    // we fill put the output at this path
    NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    
    // loop through the items and export
    for (MPMediaItem* item in items)
    {
        title = [item valueForProperty:MPMediaItemPropertyTitle];
        url = [item valueForProperty:MPMediaItemPropertyAssetURL];
    
        NSLog(@"Title: %@, URL: %@",title,url);
    
        theAsset = [AVAsset assetWithURL:url];
    
        if ([theAsset hasProtectedContent]) {
            NSLog(@"%@ is protected.",title);
        } else {
            NSLog(@"%@ is NOT protected.",title);
        }
    
        exportSession = [[AVAssetExportSession alloc] initWithAsset:theAsset presetName:AVAssetExportPreset640x480];
    
        storePath = [applicationDocumentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mov",title]];
    
        exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    
        exportSession.outputURL = [NSURL fileURLWithPath:storePath];
    
        [exportSession exportAsynchronouslyWithCompletionHandler:^{
            NSLog(@"done!");
        }];
    
    }
    

    Out of curiosity, are you checking the AVAsset exportable flag?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched for a general solution to this but only find answers to
I have searched about this but can't seem to find exactly how to do
I have read through the docs but cannot figure out if this is possible.
I have read the documentation and searched all over but I can't find how
I have searched all morning and yesterday afternoon and still cannot find an solution
Apologies, but I have searched and read previous answers on this question but couldn't
I have searched for a CGI and read about it but nothing useful found.
I have searched here, GooBingHooVista'd the world and read this related question for VS
I have searched and searched for this but I think my terminology isn't correct
I've read through the docs and searched on here, but I'm not quite understanding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.