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透视脚... 透视详细!aapoker透视脚本下载,aapoker透视脚本下载-都是有辅助方法(哔哩哔哩)1、上手...
透视关于!wepoker透视有... 透视关于!wepoker透视有没有,wepoker透视脚本下载-好像真的是有辅助方法(哔哩哔哩)1、...
透视有挂!wepoker手机插... 透视有挂!wepoker手机插件,wejoker开挂-竟然是有辅助app(哔哩哔哩)1、首先打开辅助...
透视解迷!aapoker ai... 透视解迷!aapoker ai插件,aapoker辅助怎么用-本来是真的有辅助神器(哔哩哔哩)1、游...
透视必备!aapoker安装包... 透视必备!aapoker安装包怎么使用,aapoker脚本怎么用-确实真的有辅助方法(哔哩哔哩)1、...
透视开挂!wpk软件是真的吗,... 透视开挂!wpk软件是真的吗,wpk俱乐部是做什么的-一直有辅助app(哔哩哔哩)1、下载好正确养号...
透视揭幕!wpk透视工作室,w... 透视揭幕!wpk透视工作室,wpk私人辅助-真是是真的有辅助app(哔哩哔哩)1、许多玩家不知道辅助...
透视分享!wpk是真的还是假的... 透视分享!wpk是真的还是假的,wpk安卓下载辅助-一贯是有辅助教程(哔哩哔哩)1、首先打开辅助器下...
透视总结!wpk有那种辅助吗,... 透视总结!wpk有那种辅助吗,wpk透视怎么安装-真是真的有辅助攻略(哔哩哔哩)1、辅助器安装包、辅...
透视开挂!wepoker私人局... 透视开挂!wepoker私人局辅助器怎么用,wepoker俱乐部辅助器-一直有辅助软件(哔哩哔哩)透...