简体   繁体   English

iOS 7:奇怪的AVAssetExportSession错误

[英]iOS 7: Strange AVAssetExportSession bug

I have used AVAssetExportSession to join 2 video files. 我使用AVAssetExportSession加入了2个视频文件。 It works fine in iOS 6 but has very strange bug in iOS 7. Let me explain this bug. 它在iOS 6中运行良好,但在iOS 7中有一个非常奇怪的错误。让我解释一下这个bug。 I have 2 video files, the first video is 8 seconds duration and the second is 81 seconds duration. 我有2个视频文件,第一个视频持续时间为8秒,第二个视频持续时间为81秒。 In iOS7, it will be fine if I do the second + the first. 在iOS7中,如果我做第二个+第一个就没关系。 But if I do the first + the second, it will be error: 但如果我做第一个+第二个,那将是错误的:

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x176cb5c0 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x176ca000 "The operation couldn't be completed. (OSStatus error -12633.)", NSLocalizedFailureReason=An unknown error occurred (-12633)} 错误域= AVFoundationErrorDomain代码= -11800“操作无法完成”UserInfo = 0x176cb5c0 {NSLocalizedDescription =操作无法完成,NSUnderlyingError = 0x176ca000“操作无法完成。(OSStatus error -12633。)”, NSLocalizedFailureReason =发生未知错误(-12633)}

I have checked exportPresetsCompatibleWithAsset and supportedFileTypes . 我检查了exportPresetsCompatibleWithAssetsupportedFileTypes There is no problem with it. 它没有问题。 Could anyone tell how to fix this? 谁能说出如何解决这个问题? Any help would be appreciated. 任何帮助,将不胜感激。

Does anyone know this bug :(. I provide 2mp4 files which cause the bug: test 1 , test 2 . Do join "test 2" + "test 1" is fine, but do "test 1" + "test 2" will cause an error. It only happens in iOS7 有没有人知道这个bug :(。我提供2mp4文件导致错误: 测试1测试2.加入“测试2”+“测试1”是好的,但做“测试1”+“测试2”将导致错误。它只发生在iOS7中

I found that you can replace AVAssetExportSession with SDAVAssetExportSession . 我发现你可以用AVAssetExportSession替换SDAVAssetExportSession You can then specify settings instead of using presets which provide different results across different devices. 然后,您可以指定设置,而不是使用在不同设备上提供不同结果的预设。

I had to change __weak typeof(self) wself = self; 我不得不改变__weak typeof(self) wself = self; to __weak SDAVAssetExportSession * wself = self; to __weak SDAVAssetExportSession * wself = self; on line 172 of SDAVAssetExportSession.m . SDAVAssetExportSession.m第172 SDAVAssetExportSession.m

I had an "unknown error occurred (-12633)" message. 我发生了“未知错误(-12633)”消息。

Found the answer to be adding two samples with same timestamp . 找到了添加两个具有相同时间戳的样本的答案。

Apparently error -12633 is an InvalidTimestamp. 显然错误-12633是InvalidTimestamp。

See this SO post -> AVAssetWriter unknown error 看到这个SO帖子 - > AVAssetWriter未知错误

If you are using methods insertTimeRanges or insertTimeRange , you need to ensure that the input time ranges are valid. 如果使用insertTimeRangesinsertTimeRange方法,则需要确保输入时间范围有效。 To be more specific, you should not use the asset's duration for this, you need to get the accurate time ranges from individual asset tracks. 更具体地说,您不应该使用资产的持续时间,您需要从单个资产跟踪中获取准确的时间范围。

Use command ffprobe -show_frames path_to_file to inspect your video files, which sometimes may be very helpful. 使用命令ffprobe -show_frames path_to_file检查视频文件,这有时可能非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM