Skip to content

How playback works

Most media servers decide between “direct play” and “transcode”. Naelox has three tiers, and the whole design leans toward the first two, because every transcode costs quality, electricity and a fan spinning up.

If the container and every codec in the file are things the device plays natively, Naelox serves the file itself, with HTTP byte-range requests for seeking. Nothing is touched. On Apple devices that means MP4 or MOV with H.264 or HEVC video and AAC, AC-3, E-AC-3, ALAC or FLAC audio.

Most libraries are MKV. Safari does not play MKV, but it does play what is inside most MKVs. So Naelox remuxes on the fly: it reads the file, rewraps the same compressed picture and audio into fragmented MP4 segments, and serves them as an HLS playlist. The picture is bit-for-bit what was in the file; the audio too, when the device decodes it. This costs almost nothing on the server.

Segment boundaries come from the file’s own keyframe index (MKV cues or the MP4 sample table), which the scanner reads once. That is what makes seeking anywhere instant: the server knows exactly where every segment starts without decoding anything.

The same HLS playlist also offers 1080p, 720p and 480p H.264 renditions, built on demand by a worker from the same keyframe index. The player picks one when the connection cannot carry the original, and moves back up when it can. A rendition is built only for the segments the player asks for, starting where the viewer is, so a seek into unplayed territory does not wait for everything before it.

Renditions are encoded at a constant quality target with the ladder bitrate as a ceiling, so a dark, still scene does not waste bits and a busy one does not fall apart. On a worker with a capable GPU this is hardware encoding; otherwise software.

The player gets one master playlist with every option: the passthrough variant and the renditions, with the audio tracks and subtitles the file has. Apple’s player chooses, and the Quality menu lets a person override it. Browsers without HEVC are offered H.264 twins so they always find something to play.

An HDR file passes through to a device that plays HDR. For renditions, a worker with 10-bit HEVC encoding keeps them HDR; without it, renditions are tone-mapped to SDR, on the GPU where OpenCL is available. Dolby Vision is badged and passes through in the profiles Apple devices accept; otherwise the HDR10 base layer plays.

Text subtitles are converted to WebVTT and served alongside. Image subtitles (PGS from Blu-ray, VobSub from DVD) are a picture per cue, which Safari cannot show in HLS, so Naelox runs them through OCR once and serves the result as text. It is not perfect, but it is readable, and it happens in the background before you press play. An image track only appears in the subtitle menu once its text is ready, so every track you can pick will show. Tracks are read ahead of time in the languages under Settings → Subtitles, on a worker that has that language installed; an admin can read any other track from the title page.

Because passthrough covers most files, you usually do not need Allspark rules to make a library playable. Rules are for the cases where you want the file itself changed: shrinking a 4K HEVC collection to 1080p H.264 copies that every device plays directly, for example. See Write a transcode rule.