Skip to content

Transcoding

The Sapsan transcoder (based on FFmpeg) re-encodes the input stream: changes codecs, bitrate, resolution, and prepares a multibitrate (MBR) ladder from a single source.

Configuration

The transcoder.output section describes output tracks. Each track takes a source (!content video or !content audio) and sets a codec:

streams:
  tv1:
    inputs:
    - udp: {host: 239.0.0.1, port: 5000}
    transcoder:
      output:
      - source: !content video          # 1080p — top of the ladder
        codec: !set h264
        bitrate: 2800000
        params: !video
          gop_size: 28
          gop_structure: ipppb
      - source: !content video          # 720p
        codec: !set h264
        bitrate: 1200000
        params: !video
          gop_size: 28
          gop_structure: ipppb
          resize: !fit
            height: 720
      - source: !content audio
        codec: !set aac

Source track selection

source What it takes
!content video / !content audio a track by content type
!exact v1 a specific track by id
!best_quality video the best available quality
!language_codec [eng, aac] a track by language and codec

The if_missing parameter sets the behavior when the track is absent: drop (default — the output is not created), blank (empty signal), or substitute.

Codecs and parameters

  • codec: !set <name> — re-encode (h264, hevc, av1, aac, opus); codec: same — pass through without re-encoding (e.g. only repackage audio).
  • Outputs of different codecs from one source keep aligned timestamps and keyframes — an h264/hevc/av1 ladder stays consistent.
  • gop_size, gop_structure (e.g. ipppb) — GOP structure control, important for aligned MBR segments.
  • Audio: G.711 → AAC/Opus 48 kHz re-encoding with timeline preservation — the typical IP camera case.
  • JPEG screenshot tracks pass through the transcoder untouched.

Resizing

resize What it does
!scale exact scaling to the given dimensions
!fit fit preserving aspect ratio (with padding, background color configurable)
!crop crop to the given dimensions

Note

TODO: hardware acceleration (Nvenc/Vulkan), deinterlacing, overlays/logos, audio parameter reference.

Verification

Open the master playlist http://server/streaming/v/tv1/index.m3u8 — all output qualities should appear in it.

Next steps