我构建了一个 AVMutableComposition
带有视频轨道和音频轨道,并连接(按顺序插入)AVAssets
来自一堆.mp4
我从磁盘加载到其中的文件。
现在我想将合成结果写入磁盘,使用与源 Material 完全相同的设置(它们都是由同一个应用程序生成的,一个安全摄像头系统)。
AVAssetExportSession
需要一个命名的预设。我可以选择像 AVAssetExportPresetHEVCHighestQuality
这样的东西但这意味着重新编码,我觉得应该有一种方法可以以更无损的方式做到这一点。
当我检查与我的作品兼容的预设时,我得到 p>
["AVAssetExportPreset1920x1080", "AVAssetExportPresetLowQuality", "AVAssetExportPresetAppleM4V720pHD", "AVAssetExportPresetAppleM4VAppleTV", "AVAssetExportPresetAppleM4A", "AVAssetExportPresetHEVCHighestQuality", "AVAssetExportPreset640x480", "AVAssetExportPresetAppleProRes422LPCM", "AVAssetExportPreset3840x2160", "AVAssetExportPresetHEVC3840x2160", "AVAssetExportPresetAppleM4VWiFi", "AVAssetExportPresetHighestQuality", "AVAssetExportPresetAppleM4VCellular", "AVAssetExportPreset1280x720", "AVAssetExportPresetMediumQuality", "AVAssetExportPresetAppleM4V1080pHD", "AVAssetExportPresetAppleM4V480pSD", "AVAssetExportPreset960x540", "AVAssetExportPresetAppleM4ViPod", "AVAssetExportPresetHEVC1920x1080"]
有没有更好的办法?
最佳答案
尝试使用 AVAssetExportPresetPassthrough
。
正如文档所述,它不会出现在 exportPresetsCompatibleWithAsset
的结果中(出于未提及的原因),但它通常在从兼容的源 Assets 编写 mp4s 或 movs 时有效,并且它只是收集并编写样本没有任何重新编码的数据。
关于ios - 如何以最少的重新压缩将新创建的 AVMutableComposition 写入磁盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54840018/