Skip to content

Encoding

blycr edited this page Feb 18, 2026 · 9 revisions

Encoding & Transcoding Support

MSP v0.9.0+ introduces Hardware-Accelerated Transcoding support, leveraging GPU encoders to significantly improve transcoding speed and reduce CPU usage. See Hardware Acceleration for details.

Playback Strategy: Probe-Aware Direct Play First

MSP uses a practical "probe-aware direct play first" strategy:

  1. Try-First (Direct Play):

    • MSP first attempts raw direct streaming.
    • Benefit: when direct play works, server CPU usage stays near zero.
  2. Probe-Aware Preemptive Transcode:

    • Containers with known poor browser support (AVI/WMV) are transcoded preemptively.
    • Other formats still go through direct play first, then fallback to transcode only on real failure.
    • Native WMV stream keeps explicit MIME: video/x-ms-wmv.
  3. Fallback-Next (Auto Transcode):

    • On direct-play failure, MSP performs one same-origin retry with a refreshed ts.
    • If it still fails and transcoding is enabled, MSP falls back to real-time transcoding.

Real-time Transcoding

When Direct Play fails, MSP uses ffmpeg on the server to transcode media on the fly.

Requirements

  1. The server must have FFmpeg installed.
  2. The ffmpeg command must be available in the system PATH.

Features

  • Video: Automatically converts to H.264/AAC MP4 stream.
  • Audio: Automatically converts to MP3 stream.
  • Seeking: Supported (Smart Seeking).
    • MSP v0.8.4+ supports seeking within transcoded streams. The server regenerates the stream from the new timestamp.

Configuration

For best compatibility, it is highly recommended to enable transcoding in config.json:

{
  "playback": {
    "video": { "transcode": true },
    "audio": { "transcode": true }
  }
}

Note: Enabling this does NOT mean all videos will be transcoded. Common MP4 (H.264/AAC) stays on direct play unless the container is high-risk or playback truly fails.

FAQ

Why is my MKV transcoding now?

It depends on the codec inside. H.264 inside MKV usually Direct Plays. HEVC inside MKV (if unsupported by browser) triggers transcoding.

High CPU usage during playback?

Real-time video transcoding is CPU-intensive. MSP limits concurrent transcoding sessions (default: 2) to prevent server overload.

Browser Native Support (Reference)

Most modern browsers (Chrome, Edge, Firefox, Safari) natively support:

  • Video Codecs:
    • H.264 (AVC): Best compatibility.
    • VP8 / VP9: Good compatibility.
    • H.265 (HEVC): Poor browser support. Often requires hardware support + OS extensions.
  • Audio Codecs:
    • AAC: Best compatibility.
    • MP3: Good compatibility.
    • Opus / Vorbis: Good compatibility.
    • AC-3 (Dolby): Generally unsupported in browsers.

Clone this wiki locally