Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
HEVC Video with Alpha Channel
Tachibana Kaoru
July 24, 2019
Technology
1
750
HEVC Video with Alpha Channel
Tachibana Kaoru
July 24, 2019
Tweet
Share
More Decks by Tachibana Kaoru
See All by Tachibana Kaoru
GeoLocationAnchor and MKTileOverlay
toyship
0
150
Custom Group Activities
toyship
3
880
Synchronized iPhones, Again!
toyship
2
1k
ARKit4.pdf
toyship
1
1.7k
Custom Gesture Recognizer on iOS
toyship
3
940
RealityKit & Reality Composer
toyship
3
330
ARKit3
toyship
5
6.5k
UIViewPropertyAnimator and Easing
toyship
2
690
Synchronized iPhones!
toyship
3
3.7k
Other Decks in Technology
See All in Technology
「一通りできるようになった」その先の話
hitomi___kt
0
110
SmartHRからOktaへのSCIM連携で作り出すHRドリブンのアカウント管理
jousysmiler
1
110
日経電子版だけじゃない! 日経の新規Webメディアの開発 - NIKKEI Tech Talk #3
sztm
0
150
エアドロップ for オープンソースプロジェクト
epicsdao
0
340
NGINXENG JP#2 - 3-NGINX Plus・プロダクトのアップデート
hiropo20
0
190
S3とCloudWatch Logsの見直しから始めるコスト削減 / Cost saving S3 and CloudWatch Logs
shonansurvivors
0
200
立ち止まっても、寄り道しても / even if I stop, even if I take a detour
katoaz
0
170
本社オフィスを移転し、 オフィスファシリティ・コーポレートIT を刷新した話
rotomx
3
1.2k
OpenShift.Run2023_create-aro-with-terraform
ishiitaiki20fixer
1
180
目指せCoverage100%! AutoScale環境におけるSavings Plans購入戦略 / JAWS-UG_SRE_Coverage
taishin
0
450
Pentesting Password Reset Functionality
anugrahsr
0
370
OCIコンテナサービス関連の技術詳細 /oke-ocir-details
oracle4engineer
PRO
0
760
Featured
See All Featured
How to name files
jennybc
47
73k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
657
120k
Fontdeck: Realign not Redesign
paulrobertlloyd
74
4.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
500
130k
How to Ace a Technical Interview
jacobian
270
21k
Design by the Numbers
sachag
271
18k
The Illustrated Children's Guide to Kubernetes
chrisshort
22
42k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
101
6.2k
For a Future-Friendly Web
brad_frost
166
7.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
120
29k
Reflections from 52 weeks, 52 projects
jeffersonlam
338
18k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
38
3.6k
Transcript
HEVC Video with Alpha Channel @TachibanaKaoru 2019/7/24 #potatotips
About Me @TachibanaKaoru Freelance iOS Engineer झຯɿϘϧμϦϯάɺBotWͰཾͷྡྷङ ࠷ۙͷςʔϚɿཱྀΛ͠ͳ͕ΒࣄΛ͢Δ όϦౡɺαϯτϦʔχౡɺόϯίΫɺόϧηϩφɺΞΠεϥϯυ
Alpha Channel alpha channel each pixel include transparency information popular
in images
Alpha Channel alpha channel each pixel include transparency information popular
in images
video codec support alpha channel Apple ProRes 4444 WebM VP8
media with alpha Image Video High bitrate PNG, TIFF Apple
ProRes 4444 Flexible bitrate HEIF, HEIFS HEVC with alpha
HEVC support os iOS 13~ tvOS13 ~ macOS Catalina ~
Playback AVPlayerͰͷ࠶ੜ
Demo Sample Code https://github.com/TachibanaKaoru/ HEVCAlphaSample
Encoding HEVC video with API Color Chroma key from Apple
ProRes 4444 to HEVC with alpha
Color Chroma key
let asset = AVAsset(url: sourceURL) guard let exportSession = AVAssetExportSession(asset:
asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { print("Failed to create export session to HEVC with alpha.") handleExportCompletion(.failed) return } // Make CIFilter let filter = makeChromaKeyFilter(usingHueFrom: 0.3, to: 0.4, brightnessFrom: 0.05, to: 1.0 ) let chromaKeyComposition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in let source = request.sourceImage.clampedToExtent() filter.setValue(source, forKey: kCIInputImageKey) let output = filter.outputImage! // Provide the filter output to the composition request.finish(with: output, context: nil) }) // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.videoComposition = chromaKeyComposition exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) }
let asset = AVAsset(url: sourceURL) guard let exportSession = AVAssetExportSession(asset:
asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { print("Failed to create export session to HEVC with alpha.") handleExportCompletion(.failed) return } // Make CIFilter let filter = makeChromaKeyFilter(usingHueFrom: 0.3, to: 0.4, brightnessFrom: 0.05, to: 1.0 ) let chromaKeyComposition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in let source = request.sourceImage.clampedToExtent() filter.setValue(source, forKey: kCIInputImageKey) let output = filter.outputImage! // Provide the filter output to the composition request.finish(with: output, context: nil) }) // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.videoComposition = chromaKeyComposition exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) }
let asset = AVAsset(url: sourceURL) guard let exportSession = AVAssetExportSession(asset:
asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { print("Failed to create export session to HEVC with alpha.") handleExportCompletion(.failed) return } // Make CIFilter let filter = makeChromaKeyFilter(usingHueFrom: 0.3, to: 0.4, brightnessFrom: 0.05, to: 1.0 ) let chromaKeyComposition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in let source = request.sourceImage.clampedToExtent() filter.setValue(source, forKey: kCIInputImageKey) let output = filter.outputImage! // Provide the filter output to the composition request.finish(with: output, context: nil) }) // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.videoComposition = chromaKeyComposition exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) }
from Apple ProRes 4444 to HEVC with alpha
let asset = AVAsset(url: sourceURL) AVAssetExportSession.determineCompatibility(ofExportPreset: AVAssetExportPresetHEVCHighestQualityWithAlpha, with: asset, outputFileType:
.mov) { compatible in if compatible { guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { handleExportCompletion(.failed) return } // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) } } else { handleExportCompletion(.failed) } }
let asset = AVAsset(url: sourceURL) AVAssetExportSession.determineCompatibility(ofExportPreset: AVAssetExportPresetHEVCHighestQualityWithAlpha, with: asset, outputFileType:
.mov) { compatible in if compatible { guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { handleExportCompletion(.failed) return } // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) } } else { handleExportCompletion(.failed) } }
let asset = AVAsset(url: sourceURL) AVAssetExportSession.determineCompatibility(ofExportPreset: AVAssetExportPresetHEVCHighestQualityWithAlpha, with: asset, outputFileType:
.mov) { compatible in if compatible { guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { handleExportCompletion(.failed) return } // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) } } else { handleExportCompletion(.failed) } }
·ͱΊ HEVCiOS13͔Β͑ΔAlpha͖ͭಈըϑΥʔϚοτͰ͢ɻ ࠶ੜAVPlayerWKWebViewͰ؆୯ʹͰ͖·͢ɻ SpriteKitɺSceneKitɺMetalͰ࠶ੜՄೳɻARͰ͑·͢ɻ
Links HEVC Video with Alpha https://developer.apple.com/videos/play/wwdc2019/506/ Using HEVC Video with
Alpha https://developer.apple.com/documentation/avfoundation/ media_assets_playback_and_editing/using_hevc_video_with_alpha HEVC Video with Alpha https://developer.apple.com/av-foundation/HEVC-Video-with-Alpha-Interoperability- Profile.pdf