0

I am trying to export a QuickTime movie file with a video track in DNxHD and a couple of audio tracks in "Integer (Little Endian)", into a natively supported codec, like h.264.

The export succeeds with the code below but unfortunately the output movie only contains the audio track (in AAC, which is ok). Why is it not transcoding the video track, despite not reporting any errors?

The code:

NSURL * url = [NSURL fileURLWithPath:inPath];
NSDictionary * options = @{ AVURLAssetPreferPreciseDurationAndTimingKey : @YES };
AVURLAsset * asset = [[[AVURLAsset alloc] initWithURL:url options:options] autorelease];

AVAssetExportSession * exportSession =
[AVAssetExportSession exportSessionWithAsset:asset
                                  presetName:AVAssetExportPreset1280x720];

if (nil == exportSession)
    return NO;

exportSession.outputURL = [NSURL fileURLWithPath:outPath];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;

__block BOOL success = NO;
__block BOOL done = NO;

// perform the export
[exportSession exportAsynchronouslyWithCompletionHandler:^{

    switch ([exportSession status])
    {
        case AVAssetExportSessionStatusCompleted:
            NSLog(@"Export succeeded");
            success = YES;
            done = YES;
            break;

        case AVAssetExportSessionStatusFailed:
            NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
            done = YES;
            break;

        case AVAssetExportSessionStatusCancelled:
            NSLog(@"Export canceled");
            break;

        default:
            NSLog(@"Export Session Status: %d", exportSession.status);
            break;
    }
}];

while (!done)
    usleep(1000*250);

return success;
apalopohapa
  • 185
  • 3
  • 11
  • Are you reaching the `NSLog(@"Export succeeded");` line? Do you see `Export succeeded` in the console? – agressen May 13 '14 at 10:33
  • @agressen Yes, "Export succeeded" gets printed. I don't think transcoding from 3rd party is supported. The same code works when the movie already has a supported codec. When QT X opens the DNxHD movie, it uses something called CoreMediaAuthoringSessionHelper inside the private framework CodeMediaAuthoring. I ended up using the ICM API, that although deprecated, works better. – apalopohapa May 13 '14 at 10:47
  • Okay. I was going to suggest using [`SDAVAssetExportSession`](https://github.com/rs/SDAVAssetExportSession) instead of the `AVAssetExportSession`. You might have more success with that since it doesn't rely on those temperamental presets. – agressen May 13 '14 at 10:55
  • @agressen Thanks, I did try it when I was working on this, and according to my notes it also fails with the DNxHD movie. – apalopohapa May 13 '14 at 11:13

0 Answers0