-
Export HDR media in your app with AVFoundation
Discover how to author and export high dynamic range (HDR) content in your app using AVFoundation. Learn about high dynamic range and how you can take advantage of it in your app. We'll show you how to implement feature sets that allow people to export HDR content, go over supported HDR formats, review current restrictions, and explore the Apple platforms that support HDR export.
Recursos
Vídeos relacionados
WWDC21
-
Buscar neste vídeo...
-
-
9:02 - AVAssetExportSession Intro
// AVAssetExportSession code snippet guard let exportSession = AVAssetExportSession(asset: sourceAsset, presetName: AVAssetExportPresetHEVCHighestQuality) else { // Handle error } exportSession.outputURL = outputURL exportSession.outputFileType = AVFileTypeQuickTimeMovie exportSession.exportAsynchronouslyWithCompletionHandler { // Handle completion } -
13:24 - AVAssetWriter with sourceFormatHint
// AVAssetWriter with sourceFormatHint let assetWriter = try AVAssetWriter(url: outputURL, fileType: AVFileTypeQuickTimeMovie) let outputSettings: [String: AnyObject] = [ AVVideoCodecKey: AVVideoCodecTypeHEVC ] let assetWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: outputSettings sourceFormatHint: videoFormatDescription) assetWriter.add(assetWriterInput) guard assetWriter.startWriting() else { throw assetWriter.error! } -
14:13 - AVAssetWriter with AVOutputSettingsAssistant
// AVAssetWriter with AVOutputSettingsAssistant let assetWriter = try AVAssetWriter(url: outputURL, fileType: AVFileTypeQuickTimeMovie) let settingsAssistant = AVOutputSettingsAssistant( preset: AVOutputSettingsPreset.hevc1920x1080) settingsAssistant.sourceVideoFormat = videoFormatDescription let newVideoSettings = settingsAssistant.videoSettings // Modify a few fields in newVideoSettings here let assetWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: newVideoSettings) assetWriter.add(assetWriterInput) guard assetWriter.startWriting() else { throw assetWriter.error! }
-