ios - 如何以最少的重新压缩将新创建的 AVMutableComposition 写入磁盘?

标签 ios swift macos avfoundation

我构建了一个 AVMutableComposition带有视频轨道和音频轨道,并连接(按顺序插入)AVAssets来自一堆.mp4我从磁盘加载到其中的文件。

现在我想将合成结果写入磁盘,使用与源 Material 完全相同的设置(它们都是由同一个应用程序生成的,一个安全摄像头系统)。

AVAssetExportSession需要一个命名的预设。我可以选择像 AVAssetExportPresetHEVCHighestQuality 这样的东西但这意味着重新编码,我觉得应该有一种方法可以以更无损的方式做到这一点。

当我检查与我的作品兼容的预设时,我得到

["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/

相关文章:

ios - 延迟后播放AVAudioPlayer

ios - 无法从项目包中提取图像路径

具有递归枚举的 Swift Codable 协议(protocol)

macos - ./配置 : No such file or directory - build nginx-rtmp-module on Mac OS X

macos - 为什么 CGContextShowGlyphsAtPositions() 不起作用,而 CGContextShowGlyphsAtPoint() 起作用?

ios - 将 Xcode 5 降级到 Xcode 4.6 后仪器停止工作

ios - 我如何从 Facebook 用户 ID 获取 Facebook 访问 token ?

ios - iPhone 模拟器屏幕截图尺寸不正确

xcode - 如何使用 Xcode 7 和 8 编译针对最新 SDK 的 Swift 代码?

ios - Swift 泛型 : function with T. 类型作为参数返回可选 T