Pixel Prism
Pixel Prism is the media engine in Pixel Brite. It converts video and audio while you watch, keeps HDR intact, and runs on Apple, Windows, and Linux hardware as old as the 2015 Apple TV HD.
Why convert at all
A video only plays directly if your device supports its codec and your connection can carry its bitrate. Otherwise it has to be converted. Converting ahead of time means storing a copy for each device and quality, and spending hours encoding movies you may never watch.
Prism converts while you watch, and only the parts you watch.
How on-demand conversion works
Prism gives the player one HLS playlist for the whole movie. It lists every quality and format the device can use, and none of those segments exist yet.
The player picks the best entry it supports and asks for a segment, for example 720p at the 8 second mark. Prism makes that segment, sends it, and waits for the next request. Each request names the codec, resolution, frame rate, dynamic range, and exact start and end time, so Prism produces exactly what was asked for.
A track your device can already play is copied into the segment unchanged. Only what it can’t play is encoded. When you stop watching, encoding stops.
Every quality for a movie comes from one running process. Changing quality or seeking is a new request to that process, so no encoder has to start up again.
Why not just run FFmpeg
FFmpeg on its own races ahead and encodes far more of the movie than the player needs. You can pause it, but it still produces one stream at one quality, and playback doesn’t stay at one quality. Your connection slows down, you switch to picture in picture, or you send the movie to an AirPlay receiver.
With Prism, each of those is the same event: the player or receiver picks a different entry from the same playlist. A seek is a request for a later segment. This is all standard HLS, so players such as AVPlayer work unmodified.
Segments that join cleanly
Encoders add a few priming samples at the start of audio, and video segments need frames from before the cut to decode. Encoded separately, segments glitch where they meet. Prism records that priming and preroll in each segment’s timing so the player skips it, and picture and sound play straight across segment boundaries.
Music
Music adapts the way video does. Prism offers Opus at several bitrates, lossless FLAC at the source’s sample rate, and the original track, and the player moves between them at segment boundaries as the connection changes, even when the codec changes. Tracks that are already cached play at the highest quality.
Tracks end exactly where they were authored, so albums play without gaps.
HDR
HDR10+ and Dolby Vision carry metadata for every frame that describes the picture’s geometry and brightness. A plain resize leaves it wrong, and a re-encode drops it. Prism rewrites it to match the new size and reattaches it after encoding, so HDR stays intact when your connection drops the stream to 480p.
Prism converts Dolby Vision Profile 5 to Profile 8.1 for devices that only play 8.1, and adds HDR10+ or Dolby Vision metadata when a title carries only one of them. On Apple devices, HDR is downscaled in linear light.
Put your GPU to work
Decoding, scaling, color conversion, and encoding stay on the GPU: VideoToolbox and Metal on Apple devices, VAAPI, Vulkan, and CUDA on Linux, and Direct3D 11 on Windows. Frames aren’t copied back to the CPU between steps.
Streams running at the same time share one GPU device and one cache of compiled shaders, so a new stream starts without compiling them again.
Film and interlaced video
TV recordings and DVDs often store film as interlaced fields in a 3:2 pattern. Prism detects that pattern on the GPU and rebuilds the original film frames. Video that was shot interlaced is deinterlaced on the GPU.
Broadcast captions
US TV captions (CEA-608 and CEA-708) are drawn with their authored windows, colors, positions, and effects. Each caption service is its own track, and captions move up when the player’s controls are on screen. Captions are kept when Prism re-encodes video with Apple’s hardware encoder.
DVDs, Blu-rays, and disc images
DVD and Blu-ray folders and ISO images play with their authored titles and chapters, without remuxing. A DVD seek jumps through the disc’s own navigation data to the right spot.
Less reading over the network
Seek points, subtitles, and track details come from a file’s own index, such as MP4 sample tables and Matroska Cues. Prism reads those parts of the file and skips the media, which matters when the movie is on a network share.
Faster audio codecs
DTS and DTS-HD Master Audio decoding and AAC encoding have vector code for ARM (NEON) and x86 (SSE2, AVX2, and AVX-512). It produces exactly the same output as the code it replaces.
Built on
Prism is built on FFmpeg, libplacebo, mpv, and libass, with my changes to each. On Apple devices it uses Network.framework for HTTPS and the system’s audio codecs, and the apps that include it need no JIT entitlement.