AVAssetExportSession失败

编程入门 行业动态 更新时间:2024-10-13 02:18:25
AVAssetExportSession失败 - 合并2个WAV文件(iOS7)(AVAssetExportSession fails - Merging 2 WAV files (iOS7))

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

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

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值)。

我在这里错过了很明显的东西吗 此代码适用于iOS6。 随时让我知道,如果我需要提供更多的信息,并提前感谢您可以提供任何方向!

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

( "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,所以我没有理由认为它会因这种错误而失败。

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

我用视频(mp4)文件测试了这个SAME代码,并且它在iOS7中完美运行。 我使用了相同的代码,并对WAV,CAF和M4A文件进行了调整,并且每次都出现“该操作不支持该介质”的问题。 错误。

这是Apple代码中的错误,还是我们甚至可以在iOS7中使用音频文件来做到这一点? 我没有在“iOS7新增功能”文档的Apple AV Foundation部分中看到有关此问题的任何具体内容,而在iOS6中,这似乎工作正常。 我可能会就此与苹果进行接触。

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.

最满意答案

我向苹果提交了一份TSI,之后不久我收到了一个回应:

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

他们指示我继续并通过bugreport.apple.com提交bug,所以我这样做了。 希望他们能够得到解决,因为我们有相当多的功能驻留在此。

我的希望是,如果他们遇到了这个问题,这可以帮助他人节省调试时间。

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!

更多推荐

本文发布于:2023-08-03 18:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1398141.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AVAssetExportSession

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!