View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Explore HLS variants in AVFoundation

    Discover how you can use AVFoundation APIs to highlight different variants of your content within your app. We'll show you how you can inspect HLS content using these APIs for different video characteristics, including attributes like SDR/HDR, FPS, and the like. And we'll explore the AVAssetVariant, which represents streaming and offline content.

    Recursos

    • HTTP Live Streaming - Overview
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC21

    • Immerse your app in Spatial Audio
    • Transition media gaplessly with HLS
    • What’s new in AVFoundation

    WWDC20

    • Discover how to download and play HLS offline
  • Buscar neste vídeo...
    • 0:40 - HLS Master Playlist

      #EXTM3U
      #EXT-X-VERSION:7
      #EXT-X-INDEPENDENT-SEGMENTS
      
      #EXT-X-MEDIA:TYPE=AUDIO,NAME="English",GROUP-ID="stereo",LANGUAGE="en",DEFAULT=YES, AUTOSELECT=YES,CHANNELS="2",URI="en_stereo.m3u8"
      #EXT-X-MEDIA:TYPE=AUDIO,NAME="French",GROUP-ID="stereo",LANGUAGE="fr",DEFAULT=NO, AUTOSELECT=YES,CHANNELS="2",URI="fr_stereo.m3u8"
      
      #EXT-X-MEDIA:TYPE=AUDIO,NAME="English",GROUP-ID="atmos",LANGUAGE="en",DEFAULT=YES, AUTOSELECT=YES,CHANNELS="16/JOC",URI="en_atmos.m3u8"
      #EXT-X-MEDIA:TYPE=AUDIO,NAME="French",GROUP-ID="atmos",LANGUAGE="fr",DEFAULT=NO, AUTOSELECT=YES,CHANNELS="16/JOC",URI="fr_atmos.m3u8"
      
      #EXT-X-STREAM-INF:BANDWIDTH=14516883,VIDEO-RANGE=SDR,CODECS="avc1.64001f,mp4a.40.5", AUDIO="stereo",FRAME-RATE=23.976,RESOLUTION=1920x1080
      sdr_variant.m3u8
      
      #EXT-X-STREAM-INF:BANDWIDTH=34516883,VIDEO-RANGE=PQ,CODECS="dvh1.05.06,ec-3", AUDIO="atmos",FRAME-RATE=23.976,RESOLUTION=3840x1920
      dovi_variant.m3u8
    • 3:38 - Peak bitrate cap predicate

      let peakBitRateCap = NSPredicate(format: "peakBitRate < 5000000")
      
      let peakBitRateCapQualifier = AVAssetVariantQualifier(predicate: peakBitRateCap)
    • 3:55 - HDR predicate

      let hdrOnlyPredicate = NSPredicate(format: "videoAttributes.videoRange == %@", argumentArray: [AVVideoRange.pq])
      
      let hdrOnlyQualifier = AVAssetVariantQualifier(predicate: hdrOnlyPredicate)
    • 4:46 - Content configuration

      let variantPref = AVAssetVariantQualifier(predicate: NSPredicate(format: "videoAttributes.videoRange == %@ && peakBitRate < 5000000", argumentArray: [AVVideoRange.pq]))
      
      let myMediaSelections : [AVMediaSelection] = [enAudioMS, frAudioMS, enLegibleMS] //English, French audio and English subtitle renditions 
      
      let contentConfig = AVAssetDownloadContentConfiguration()
      
      contentConfig.variantQualifiers = [variantPref]
      
      contentConfig.mediaSelections = myMediaSelections
    • 6:29 - Download configuration

      let asset = AVURLAsset(url: URL(string: "http://example.com/master.m3u8")!)
      let dwConfig = AVAssetDownloadConfiguration(asset: asset, title: "my-title")
      
      /* Primary content config */
      let varPref = NSPredicate(format: "videoAttributes.videoRange == %@ && peakBitRate < 5000000", argumentArray: [AVVideoRange.pq])
      let varQf = AVAssetVariantQualifier(predicate: varPref)
      
      dwConfig.primaryContentConfiguration.variantQualifiers = [varQf]
      dwConfig.primaryContentConfiguration.mediaSelections = [enAudioMS, frAudioMS, enLegibleMS] //English, French audio and English subtitle renditions 
      
      /* Aux content config */
      let auxVarPref = NSPredicate(format: "%d IN audioAttributes.formatIDs", argumentArray: [kAudioFormatAppleLossless])
      let auxVarQf = AVAssetVariantQualifier(predicate: auxVarPref)
      
      let auxContentConfig = AVAssetDownloadContentConfiguration()
      auxContentConfig.variantQualifiers = [auxVarQf]
      auxContentConfig.mediaSelections = [enAudioMS] //english audio
      dwConfig.auxiliaryContentConfigurations = [auxContentConfig]
      
      dwConfig.optimizesAuxiliaryContentConfigurations = true
    • 7:42 - Download task

      let myAssetDownloadDelegate = MyDownloadDelegate()
      let avurlsession = AVAssetDownloadURLSession(configuration: URLSessionConfiguration.background(withIdentifier: "my-background-session"), assetDownloadDelegate: myAssetDownloadDelegate, delegateQueue: OperationQueue.main)
      
      let asset = AVURLAsset(url: URL(string: "http://example.com/master.m3u8")!)
      let dwConfig = AVAssetDownloadConfiguration(asset: asset, title: “my-title”)
      
      ...
      
      let downloadTask = avurlsession.makeAssetDownloadTask(downloadConfiguration: dwConfig)
      
      downloadTask.resume()
      
      let progress = downloadTask.progress
    • 8:10 - Direct variant selection

      /* Example for direct variant selection */
      
      let asset = AVURLAsset(url: URL(string: "http://example.com/master.m3u8")!)
      let dwConfig = AVAssetDownloadConfiguration(asset: asset, title: "my-title")
      
      /* Primary content config */
      let myVariant : AVAssetVariant = ...
      let myMediaSelections : [AVMediaSelection] = ...
      
      let variantQf = AVAssetVariantQualifier(variant: myVariant)
      
      dwConfig.primaryContentConfiguration.variantQualifiers = [variantQf]
      dwConfig.primaryContentConfiguration.mediaSelections = myMediaSelections
      
      /* Aux content config */
      let myAuxVariant : AVAssetVariant = ...
      let myAuxMediaSelections : [AVMediaSelection] = ...
      
      let auxVariantQf = AVAssetVariantQualifier(variant: myAuxVariant)
      
      let auxContentConfig = AVAssetDownloadContentConfiguration()
      auxContentConfig.variantQualifiers = [auxVariantQf]
      auxContentConfig.mediaSelections = myAuxMediaSelections
      dwConfig.auxiliaryContentConfigurations = [auxContentConfig]

Developer Footer

  • Vídeos
  • WWDC21
  • Explore HLS variants in AVFoundation
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines