How kartik-venugopal/swift-ffmpeg-player works
FFmpeg Player is a macOS audio-player demo: the user opens a file, its audio is demuxed and decoded, PCM is resampled and buffered, and AVAudioEngine schedules it for playback. The app also displays metadata and cover art and supports seeking; packet-table duration and seek indexing cover files without usable duration data. The graph follows the documented product stages and sampled call/data evidence; some UI-to-player wiring and unsampled subsystem details are omitted where source excerpts do not establish the exact links.
Main entry points: FFmpegDecoder.swift Frame decoder · FFmpegFormatContext.swift Format context · Player.swift Playback scheduler · AudioFileContext.swift Audio file context
Components 21
App interface
- Player controls
Sources/UI/PlayerViewController.swift - App lifecycle
Sources/AppDelegate.swift - Metadata display
Sources/UI/PlayerViewController.swift
Media access
- Format context
Sources/FFmpeg/Wrappers/FFmpegFormatContext.swift - Audio file context
Sources/FFmpeg/Wrappers/AudioFileContext.swift - Audio stream
Sources/FFmpeg/Wrappers/FFmpegAudioStream.swift - Cover art stream
Sources/FFmpeg/Wrappers/FFmpegImageStream.swift - Packet reading
Sources/FFmpeg/Wrappers/FFmpegPacket.swift - Packet seek table
Sources/FFmpeg/Utils/FFmpegPacketTable.swift
Decode and convert
- Frame decoder
Sources/FFmpeg/Utils/FFmpegDecoder.swift - Audio codec
Sources/FFmpeg/Wrappers/FFmpegAudioCodec.swift - Decoded frames
Sources/FFmpeg/Wrappers/FFmpegFrame.swift - PCM resampler
Sources/FFmpeg/Wrappers/FFmpegResamplingContext.swift - PCM buffers
Sources/FFmpeg/Utils/FFmpegDecoder+PCMBuffer.swift
Audio playback
- Playback scheduler
Sources/Player/Player.swift - Buffer scheduling
Sources/Player/PlayerScheduling.swift - Audio engine
Sources/Player/AudioEngine.swift
Track information
- Metadata reader
Sources/FFmpeg/Utils/FFmpegMetadataReader.swift - Track information
Sources/Metadata/TrackInfo.swift
Other components
- Listener
- Audio output
Connections 23
- Listener → Player controls: opens and controls
- Player controls → Playback scheduler: controls playback
- Playback scheduler → Audio file context: opens file
- Audio file context → Format context: creates context
- Format context → Audio stream: selects stream
- Format context → Cover art stream: selects cover art
- Frame decoder → Packet reading: reads packets
- Packet reading → Format context: reads from
- Frame decoder → Audio codec: decodes packets
- Audio codec → Decoded frames: produces frames
- Frame decoder → Decoded frames: queues frames
- Frame decoder → PCM resampler: converts samples
- Frame decoder → PCM buffers: builds buffers
- Playback scheduler → Frame decoder: requests frames
- Playback scheduler → Buffer scheduling: schedules audio
- Buffer scheduling → Audio engine: enqueues buffers
- Audio engine → Audio output: renders audio
- Format context → Packet seek table: builds seek index
- Playback scheduler → Audio file context: seeks stream
- Format context → Metadata reader: reads tags
- Audio file context → Track information: provides track data
- Player controls → Metadata display: displays metadata
- Metadata display → Listener: shows track details