18.1 · AVPlayer, time, and editing with compositions
AVFoundation is the engine behind every Apple video and audio app. Its mental model is small: assets describe media, items carry playback state, a player plays them, and time is a rational number, not a float.
Mental model. Media is asynchronous and stateful. Nothing is ready until you are told, and time is exact only if you keep it as a fraction.
Playing media
Player, item, asset, status, buffering and time.
- How do AVAsset, AVPlayerItem and AVPlayer fit together, what is CMTime, and why does playback “not start”?
Three objects and a clock. An AVAsset (AVURLAsset) is the static description of media: its tracks, duration, metadata; it loads properties asynchronously (try…
Editing media
Compositions, tracks and time ranges.
- How do AVMutableComposition, tracks and time ranges work for editing, and how do you export the result?
An AVMutableComposition is an AVAsset you build in code by stitching segments of other assets on a timeline, without copying any media: it only records which…
More in Media & graphics
- 18.2 · The audio session, interruptions, routes and AVAudioEngine
- 18.3 · AVCaptureSession, and zero-copy pixel buffers
- 18.4 · HLS, buffering, Now Playing, remote commands, Picture in Picture and AirPlay
- 18.5 · ImageIO formats, Core Image, Metal, and SceneKit versus RealityKit
- 18.6 · VideoToolbox, tvOS focus and media, and building a playback platform
- 18.7 · Thumbnails and orientation, GIF timing, bitmap layout, and colour spaces
- 18.8 · Extents, working colour space, and a compute pass from start to finish
- 18.9 · Reading an asset, grabbing frames, reading samples, frame-exact time, and pixel buffers