Question

I am attempting to merge 2 WAV files, using an AVAssetExportSession, under iOS7. I've confirmed the files are there and don't seem to be corrupt or anything. These are WAV files that were taken from recordings done from the device itself, and they are relatively small files.

When it calls the exportAsync method, it fails immediately with an "Operation Stopped" error immediately in the completion block (reason description is: "The operation is not supported for this media"). This happens in the simulator and the device itself. See below for my exporting code:

NSError *avError = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
AVURLAsset *tmpAsset = [[AVURLAsset alloc] initWithURL:_tmpRecordingUrl options:@{AVURLAssetPreferPreciseDurationAndTimingKey: @YES}];
AVURLAsset *permAsset = [[AVURLAsset alloc] initWithURL:_url options:@{AVURLAssetPreferPreciseDurationAndTimingKey: @YES}];
AVMutableComposition *composition = [AVMutableComposition composition];

[composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, permAsset.duration) ofAsset:permAsset atTime:kCMTimeZero error:&avError];
[composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, tmpAsset.duration) ofAsset:tmpAsset atTime:CMTimeMakeWithSeconds(_positionSlider.value, 1) error:&avError];

AVAssetExportSession *export = [[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetPassthrough];

if ([fileManager fileExistsAtPath:[_workingUrl path]]) {
    [fileManager removeItemAtURL:_workingUrl error:&avError];
}

export.outputFileType = AVFileTypeWAVE;
export.outputURL = _workingUrl;

[export exportAsynchronouslyWithCompletionHandler:^(void) {
    // fails
}];

I've also confirmed that the "avError" never gets populated, so there doesn't seem to be an issue with inserting the timeRanges or creating the export session. I did a check on the assets, and they are both readable, playable, and exportable (per the bool values on the obj).

Am I missing something obvious here? This code works fine with iOS6. Feel free to let me know if I need to provide more info, and thanks in advance for any direction you can offer!

EDIT #1: I tried adding in the track mechanism, similar to what this post has: AVAssetExportSession - Join 2 mp4 files in IOS, but no luck there, same issue. Also, if needed to know, the same error occurs when I switched to from WAV to CAF. Here is what I get when I print out the supportedFileTypes for when trying to use any audio-type format:

(
"com.apple.quicktime-movie",
"com.apple.m4a-audio",
"public.mpeg-4",
"com.apple.m4v-video",
"public.3gpp",
"org.3gpp.adaptive-multi-rate-audio",
"com.microsoft.waveform-audio",
"public.aiff-audio",
"public.aifc-audio",
"com.apple.coreaudio-format"
)

Since the audio formats are in there, and the exporter is returning YES for both assets being exportable, playable, and readable, I see no reason why it would fail with this kind of error.

EDIT #2: Some additional info - even when I strip the code down to its bare minimum, just creating an AVAsset from an NSURL, then feeding it to the AVAssetExportSession with the passthrough preset, it still just fails in iOS7. There has to be something I'm missing here.

I tested this SAME code with video (mp4) files, and it works perfectly in iOS7. I took the same code and adjusted it for WAV, CAF, and M4A files, and it failed every time with a "The operation is not supported for this media." error.

Is this a bug in Apple's code, or are we even able to do this with audio files anymore with iOS7? I don't see anything specifically about this in Apple's AV Foundation section of the "What's New in iOS7" documentation, and in iOS6, this seems to work fine. I am probably going to engage Apple on this.

Was it helpful?

Solution

I filed a TSI on this with Apple, and I received a response soon after:

Thank you for contacting Apple Developer Technical Support (DTS). Our engineers have reviewed your request and have determined that you are experiencing a known bug for which there is no known workaround at this time.

They instructed me to go ahead and file a bug via bugreport.apple.com, so I did so. Hopefully they can get a fix in for it, as we have quite a bit of functionality residing on this.

My hopes are that this helps others save time on debugging pains with this if they run into it as well!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top