AVAssetWriter错误-12743添加HDR元数据
创始人
2024-11-12 20:30:13
0

错误代码-12743表示AVAssetWriter无法添加HDR元数据。要解决此问题,您可以尝试以下解决方法:

  1. 检查是否支持HDR:在使用AVAssetWriter之前,首先检查设备是否支持HDR。您可以使用AVCaptureDevice类的isHDRVideoSupported属性来确定设备是否支持HDR。如果设备不支持HDR,则无法添加HDR元数据。
if let device = AVCaptureDevice.default(for: .video), device.isHDRVideoSupported {
    // HDR is supported
} else {
    // HDR is not supported
}
  1. 检查输出格式:确保您设置的输出格式支持HDR。您可以使用AVCaptureVideoDataOutput的availableVideoCodecTypes属性获取设备支持的视频编解码器类型,并确保选择的编码器支持HDR。
let videoDataOutput = AVCaptureVideoDataOutput()
let availableCodecs = videoDataOutput.availableVideoCodecTypes
// Check if any codec supports HDR
let hdrSupportedCodecs = availableCodecs.filter { codec in
    let supportsHDR = codec.supportsHDR
    return supportsHDR
}
// Select a codec that supports HDR
let selectedCodec = hdrSupportedCodecs.first
// Set the selected codec to output settings
videoDataOutput.setSampleBufferDelegate(self, queue: DispatchQueue.main)
videoDataOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA,
                                 AVVideoCodecKey: selectedCodec]
  1. 更新AVAssetWriter配置:如果您已经确认设备支持HDR并且选择了支持HDR的编码器,但仍然无法添加HDR元数据,可能是因为AVAssetWriter的配置不正确。请确保在创建AVAssetWriter之前正确配置它,包括设置输出URL,输出文件类型和输出设置。
let writer = try AVAssetWriter(outputURL: outputURL, fileType: .mov)
let outputSettings = [
    AVVideoCodecKey: selectedCodec,
    AVVideoCompressionPropertiesKey: [
        // Set HDR metadata
        AVVideoHDRMetadataKey: hdrMetadata
    ]
]
let videoInput = AVAssetWriterInput(mediaType: .video, outputSettings: outputSettings)
writer.add(videoInput)

请注意,上述代码示例仅供参考,并且可能需要根据您的具体需求进行适当的修改。

相关内容

热门资讯

wepok软件透明挂!微扑克后... wepok软件透明挂!微扑克后台能控制胜率吗,(AaPOKER)确实有挂(详细透视攻略方法);支持2...
wepokeai代打的胜率!德... 1、wepokeai代打的胜率!德州wepower透视辅助,(wePOke)好像真的有挂(详细辅助2...
德扑ai智能!wepoke免费... 相信很多朋友都在电脑上玩过德扑ai智能吧,但是很多朋友都在抱怨用电脑玩起来不方便。为此小编给大家带来...
wepoke确实有挂!微扑克辅... wepoke确实有挂!微扑克辅助软件下载,(wePoke)总是是有挂(详细透视德州教程);超受欢迎的...
wpk有外挂!好运大菠萝有没有... wpk有外挂!好运大菠萝有没有挂的,(aapokER)原本真的是有挂(详细透视AI教程)1、点击下载...
wpk有辅助挂!wepoke软... 大家肯定在之前wpk有辅助挂或者wpk有辅助挂中玩过wpk有辅助挂!wepoke软件收费是真的吗,(...
wepoke辅助插件!约局吧发... wepoke辅助插件!约局吧发牌逻辑,(WepOke)素来是真的有挂(详细透视详细教程)准备好在we...
wepokeai机器人!红龙扑... wepokeai机器人!红龙扑克是正规的吗,(线上德州)确实存在有挂(详细辅助攻略方法)是一款可以让...
wepoke真的有挂!aapo... wepoke真的有挂!aapoker外挂教程,(德州aa扑克)从前是真的有挂(详细辅助技巧教程);(...
aa扑克辅助!德州wpk辅助,... aa扑克辅助!德州wpk辅助,(aa poker)原本真的有挂(详细透视微扑克教程)1、不需要AI权...