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)

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

相关内容

热门资讯

重磅来袭!aapoker透视方... 自定义wepoker到底有没有透视系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用...
一分钟教会你!wepoker永... 一分钟教会你!wepoker永久免费脚本,hhpoker免费透视脚本,微扑克教程(有挂透视)1、点击...
分享一款!wepoker有没有... 分享一款!wepoker有没有挂,hhpoker是正品吗,科技教程(有挂技巧);小薇(透视辅助)致您...
技术分享!aapoker透视怎... 技术分享!aapoker透视怎么用,wepoker看底牌,2025新版教程(有挂技巧);致您一封信;...
必备科技!拱趴大菠萝有挂吗,德... 您好,拱趴大菠萝有挂吗这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在...
一分钟了解!德州私人局怎么透视... 一分钟了解!德州私人局怎么透视,pokemmo手机脚本,2025新版教程(有挂透视);原来确实真的有...
一分钟揭秘!哈糖大菠萝开挂,h... 一分钟揭秘!哈糖大菠萝开挂,hhpoker作弊码,必胜教程(有挂技巧);1.哈糖大菠萝开挂 ai辅助...
今日公布!哈糖大菠萝可以开挂吗... 今日公布!哈糖大菠萝可以开挂吗,wepoker怎么看底牌,详细教程(有挂方法)是由北京得哈糖大菠萝可...
玩家攻略!哈糖大菠萝有挂吗,佛... 玩家攻略!哈糖大菠萝有挂吗,佛手在线大菠萝智能辅助器,2025新版技巧(有挂软件);1分钟了解详细教...
最新技巧!模拟器打开hhpok... 最新技巧!模拟器打开hhpoker,wpk官网下载链接,我来教教你(有挂方法);模拟器打开hhpok...