質問

This problem has been driving me crazy. I am trying to tag some songs in my Cocoa application using an AVAsset which I am adding the tag info to it and exporting it with AVAssetExportSession. However, no matter what I do, the export fails with the error (OSStatus error -620.)" (notEnoughMemoryErr: insufficient physical memory). On my MacBook I always have 3-4 gigs or more of free RAM when I am doing this, so that can't be right. I tried removing all the tag information, in case that was causing an error somewhere, but that didn't help.

Here is the code:

AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:[tempSongPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] options:nil];

AVAssetExportSession *session;
session = [AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetAppleM4A];
session.outputFileType = AVFileTypeAppleM4A;

NSURL *outputURL = [NSURL URLWithString:[[NSString stringWithFormat:@"%@Path/%@", NSTemporaryDirectory(), @"output.m4a"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

session.outputURL = outputURL;
NSLog(@"Asset: %@", asset);
NSLog(@"Session %@", session);
[session exportAsynchronouslyWithCompletionHandler:^{


    if (AVAssetExportSessionStatusCompleted == session.status) {
        NSLog(@"Completed");
    }

    NSString *cause;
    NSString *stringError;
    if (session.error)
    {
        NSLog(@"%@", session.error);
        stringError = [session.error localizedDescription];
        cause = session.error.localizedFailureReason;

    }
    else
        stringError = @"Unknown error";
    NSLog(@"Error: %@ because %@", stringError, cause);
    for (NSString *key in session.error.userInfo.allKeys)
    {
        NSLog(@"%@: %@", key, [session.error.userInfo objectForKey:key]);
    }
}];

Any help at all? I've been stuck on this problem for two full days.

役に立ちましたか?

解決

The out-of-memory error is a red herring. The problem is this line:

NSURL *outputURL = [NSURL URLWithString:[[NSString stringWithFormat:@"%@Path/%@", NSTemporaryDirectory(), @"output.m4a"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

Try replacing it with this:

NSURL *outputURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", NSTemporaryDirectory(), @"output.m4a"] isDirectory:NO];

I've just tested with the above and it now works fine.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top