AVAssetExportSession失败 - 合并2个WAV文件(iOS7) [英] AVAssetExportSession fails - Merging 2 WAV files (iOS7)

查看:837
本文介绍了AVAssetExportSession失败 - 合并2个WAV文件(iOS7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iOS7下使用AVAssetExportSession合并2个WAV文件。我已经确认文件在那里,似乎没有腐败或任何东西。这些是从设备本身完成的录制中获取的WAV文件,它们是相对较小的文件。

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.

当它调用exportAsync方法时,它立即失败,并在完成块中立即出现Operation Stopped错误(原因描述为:此操作不受支持媒体)。这发生在模拟器和设备本身。请参阅下面的导出代码:

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
}];

我也确认avError永远不会被填充,所以似乎没有是插入timeRanges或创建导出会话的问题。我对资产进行了检查,它们都是可读的,可播放的和可导出的(根据obj上的bool值)。

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).

我错过了一些明显的东西吗?此代码适用于iOS6。如果我需要提供更多信息,请随时告诉我,并提前感谢您提供的任何方向!

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!

编辑#1 :我尝试添加跟踪机制,类似于这篇文章的内容: AVAssetExportSession - 加入IOS中的2 mp4文件,但没有运气,同样的问题。此外,如果需要知道,当我从WAV切换到CAF时会发生同样的错误。这是我在尝试使用任何音频类型格式时打印 supportedFileTypes 时得到的结果:

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"
)

由于音频格式在那里,并且导出器返回YES,因为两个资产都是可导出的,可播放的,以及可读,我认为没有理由为什么它会因这种错误而失败。

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.

编辑#2 :一些额外的信息 - 即使我剥离将代码降到最低限度,只需从NSURL创建一个AVAsset,然后通过直通预设将其提供给AVAssetExportSession,它在iOS7中仍然失败。我必须在这里找到一些东西。

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.

我用视频(mp4)文件测试了这个SAME代码,它在iOS7中运行良好。我使用相同的代码并针对WAV,CAF和M4A文件进行了调整,每次都出现此媒体不支持该操作的失败。错误。

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.

这是Apple代码中的错误,还是我们甚至无法使用iOS7对音频文件执行此操作?我在Apple的AV基础部分的iOS7中的新功能文档中没有看到任何具体的内容,在iOS6中,这似乎工作正常。我可能会和Apple讨论这个问题。

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.

推荐答案

我向Apple提交了TSI,我很快就收到了答复之后:

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


感谢您联系Apple开发者技术支持(DTS)。我们的工程师已审核了您的请求,并确定您遇到了一个已知的错误,目前还没有已知的解决方法。

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.

他们指示我继续通过bugreport.apple.com提交bug,所以我这样做了。希望他们可以为它修复,因为我们有相当多的功能。

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!

这篇关于AVAssetExportSession失败 - 合并2个WAV文件(iOS7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆