菜鸟教程小白 发表于 2022-12-11 19:15:24

ios - 特定视频的 AVAssetExportSession 失败


                                            <p><p>我正在尝试使用 AVAssetExportSession 和 AVMutableComposition 将视频和音频合并在一起。我的代码适用于大多数情况(音频和视频)。但是对于某些视频它失败了。失败的视频在 quicktime 播放器和其他播放器上运行良好。即使没有任何音频合并选项(下面给出的代码),我也只是简单地导出失败的视频。</p>

<pre><code>];
AVAssetExportSession* _assetExport = [ initWithAsset:videoAsset presetName:AVAssetExportPresetHighestQuality];
NSURL    *exportUrl = ;
if ([ fileExistsAtPath:exportPath])
{
    [ removeItemAtPath:exportPath error:nil];
}

_assetExport.outputFileType = @&#34;com.apple.quicktime-movie&#34;;
_assetExport.outputURL = exportUrl;
_assetExport.shouldOptimizeForNetworkUse = YES;
[_assetExport exportAsynchronouslyWithCompletionHandler:
^(void ) {
   if (AVAssetExportSessionStatusCompleted == _assetExport.status) {
   } else if (AVAssetExportSessionStatusFailed == _assetExport.status) {
         NSLog(@&#34;AVAssetExportSessionStatusFailed with error--%@&#34;, _assetExport.error);
   }
}
];
</code></pre>

<p>我得到的错误如下..</p>

<pre><code>Error Domain=AVFoundationErrorDomain Code=-11800 &#34;The operation could not be completed&#34; UserInfo={NSUnderlyingError=0x600000053aa0 {Error Domain=NSOSStatusErrorDomain Code=-12769 &#34;(null)&#34;}, NSLocalizedFailureReason=An unknown error occurred (-12769), NSLocalizedDescription=The operation could not be completed}
</code></pre>

<p>我没有在此处发布完整的合并代码,因为上述基本代码甚至在提到的视频中都失败了。</p>

<p>任何带有错误代码的提示或提示都会非常有用。提前致谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我通过使用 <code>AVAssetExportPresetPassthrough</code> 导出预设解决了这个问题……</p>

<pre><code>let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetPassthrough)
</code></pre>

<p>这应该使用导出文件中导入视频的分辨率。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 特定视频的 AVAssetExportSession 失败,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42802839/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42802839/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 特定视频的 AVAssetExportSession 失败