Run without a config file
Packager can run one source to one destination from command-line flags alone. It builds a complete v3 configuration from them and runs it the same way as a configuration file. Use this mode to:
- publish a test picture to a new channel in one command;
- check that a host, a firewall path or a stream key works;
- forward a camera, a file or a stream to Vindral without writing TOML;
- generate a starting configuration that you then edit.
packager start --source WHAT_TO_PUBLISH --sink WHERE_TO_PUBLISH
With Docker, the flags go after the image name, since the image's entry point is
packager:
docker run --rm "${PACKAGER_IMAGE:?Set PACKAGER_IMAGE}" start --source test-signal --sink '...'
PACKAGER_IMAGE is the image tag or digest supplied for your deployment (see
Select an image). The examples encode with libx264, so use an image that
includes x264, or add --video-encoder with a hardware H.264 encoder (see
What gets encoded).
Try it locally
This command needs no account, camera or GPU. It renders the built-in test signal and serves it as an SRT listener on UDP port 9000:
docker run --rm --name packager-signal -p 9000:9000/udp \
"${PACKAGER_IMAGE:?Set PACKAGER_IMAGE}" \
start --source test-signal --sink 'srt://:9000?mode=listener' --width 1280 --height 720
Open it in a second terminal with any SRT-capable player:
ffplay 'srt://127.0.0.1:9000'
You will see a clock, a moving ball and colour bars, and hear a beep every second
that alternates between the left and right channels. The stream is
1280×720 H.264 at 30 fps with 48 kHz stereo AAC. VLC opens the same URL. One
player can be connected at a time. Stop Packager with Ctrl+C or
docker stop packager-signal.
At startup Packager logs one line describing the pipeline. The line never shows the stream key:
INFO packager: publishing the test signal to SRT at srt://:9000: 1280x720 1.33 Mbit/s (libx264); API on 127.0.0.1:4041
For the first second or two, the transcoder and sink report waiting
(NoSourceTracks) until the source delivers media.
Publish to Vindral
Swap the sink for your channel's publish URL. The protocol is chosen from the URL
scheme. Quote the URL: SRT stream IDs contain # and !, which the shell would
otherwise interpret.
# RTMP or RTMPS
packager start --source test-signal \
--sink 'rtmps://rtmp.global.cdn.vindral.com/publish/YOUR_STREAM_KEY'
# SRT
packager start --source test-signal \
--sink 'srt://srt.global.cdn.vindral.com:3333?streamid=#!::r=YOUR_STREAM_KEY,m=publish'
# MoQ (needs the channel ID as well)
packager start --source test-signal --channel-id YOUR_CHANNEL_ID \
--sink 'https://lb.cdn.vindral.com/api/edge/moq-publish-url/YOUR_STREAM_KEY'
# Vindral WebSocket
packager start --source test-signal --sink-type vindral-ws \
--sink 'https://lb.cdn.vindral.com/api/edge/publish-url/YOUR_STREAM_KEY'
With Docker, replace the leading packager with docker run --rm "$PACKAGER_IMAGE".
Outbound connections need no published ports. A stream key accepts one publisher
at a time; stop the previous publisher before starting another one on the same key.
Choose a source
--source takes one of the following:
--source | What it reads | Notes |
|---|---|---|
test-signal | The built-in test signal | Rendered locally at 1920×1080, 30 fps by default. |
browser | A web page from --browser-url, with its audio | Needs the browser-enabled (CEF) image variant. The page must be served over http:// or https:// from a public address; local files and private-network hosts are blocked. See Browser source. |
A file path, or file:// URL | A local media file | Looped and read in real time. Mount the file into the container. |
rtmp://, rtmps:// | An RTMP stream (pull) | Read with the flv source. |
srt:// | An SRT stream | A caller URL, or a listener such as srt://:9000?mode=listener that a sender connects to. |
rtsp://, rtsps:// | An IP camera or RTSP server | Credentials go in the URL. |
udp:// | MPEG-TS over UDP | A listener URL such as udp://@:1234 works. |
http://, https:// | An HLS playlist if the path ends in .m3u8; otherwise a media file over HTTP | HLS is read in real time. |
Network sources reconnect after a drop. For example, to forward an SRT feed that a contribution encoder pushes to this host on port 9000:
docker run --rm -p 9000:9000/udp "$PACKAGER_IMAGE" \
start --source 'srt://:9000?mode=listener' \
--sink 'rtmps://rtmp.global.cdn.vindral.com/publish/YOUR_STREAM_KEY'
And a local file, looped:
docker run --rm -v "$PWD/media:/media:ro" "$PACKAGER_IMAGE" \
start --source /media/clip.mp4 \
--sink 'srt://srt.global.cdn.vindral.com:3333?streamid=#!::r=YOUR_STREAM_KEY,m=publish'
Choose a destination
--sink scheme | Protocol | Notes |
|---|---|---|
rtmp://, rtmps:// | RTMP | One video rendition only: --ladder is rejected. |
srt:// | SRT (MPEG-TS) | Caller by default. srt://:PORT?mode=listener waits for a player to connect. |
https://, http://, wss://, ws:// | MoQ | Needs --channel-id. |
Same as MoQ, with --sink-type vindral-ws | Vindral WebSocket | --channel-id does not apply. |
What gets encoded
Unless you say otherwise, Packager:
- encodes one H.264 video rendition with libx264 (
veryfast,zerolatency, 1-second GOPs) and AAC stereo audio at 128 kbit/s: one track for RTMP and SRT, every audio track of the source for MoQ and Vindral WebSocket. To MoQ or Vindral WebSocket the test signal also sends its music-only audio track and two WebVTT tracks (clock,caps); - sizes the video at 1920×1080 for the test signal and browser pages, at the file's own size for a local file, and at the source's size for a network source;
- sets the video bit rate from the pixel rate: 3 Mbit/s at 1080p30, scaled up or down for other sizes and frame rates (minimum 100 kbit/s).
Flags change this:
| Flag | Effect |
|---|---|
--width, --height | Output size. Give both. Each must be even. |
--fps | Frame rate of the test signal (1–120) or browser page (1–60). Not for encoded sources. |
--ladder | Adds two lower renditions: the next standard size down at half the bit rate, and half that size at a quarter. From 1080p you get 1080p, 720p and 360p. Not for RTMP. A network source also needs --width/--height. |
--passthrough | Forwards the source's video without re-encoding. With --ladder, the lower renditions are still encoded, cut on the source's keyframes. Audio is always encoded to AAC. RTMP carries only H.264, so the source must be H.264 there. Not for the test signal or a browser page, which are rendered. |
--video-encoder | Another H.264 encoder that takes frames from system memory, for example h264_nvenc on an NVIDIA host. Rejected if the image's FFmpeg does not have it. |
For the test signal, the burned-in title and variant can be set as well:
--test-signal-title 'Studio A' and --test-signal-variant b. See
Run two signals side by side.
Override any protocol option
--source-option key=value and --sink-option key=value set a protocol option on
the source or sink. Both are repeatable and replace generated values. A value of
true or false is a boolean, a whole number is an integer, and anything else is
a string.
# MoQ straight to a relay, without the lookup step
packager start --source test-signal --channel-id YOUR_CHANNEL_ID \
--sink 'https://YOUR_RELAY/...' --sink-option transport_mode=webtransport
# Test signal without the logo, clock shown in local time
packager start --source test-signal --sink 'srt://:9000?mode=listener' \
--source-option logo=none --source-option timezone=Europe/Stockholm
The option names are those of the source or sink type; see the test signal options and Inputs and outputs.
Reach the API and metrics
In this mode the HTTP API and /metrics listen on 127.0.0.1:4041, because
the sink URL that the API reports contains the stream key. Inside a container,
that address is not reachable from the host. Bind it explicitly and publish the
port:
docker run --rm -p 9000:9000/udp -p 127.0.0.1:4041:4041 "$PACKAGER_IMAGE" \
start --source test-signal --sink 'srt://:9000?mode=listener' --api-bind 0.0.0.0:4041
curl --fail http://127.0.0.1:4041/healthcheck
curl --fail http://127.0.0.1:4041/api/sinks
--api-bind and --log-level (trace, debug, info, warn or error) also
override a configuration file and managed mode.
Turn the command into a config file
--print-config prints the configuration the flags produce, as a runnable TOML
file, and exits without starting anything. The first line records the command that
produced it:
docker run --rm "$PACKAGER_IMAGE" \
start --source test-signal --sink 'srt://:9000?mode=listener' --width 1280 --height 720 \
--print-config > config.toml
# Generated by: packager start --source test-signal --sink 'srt://:9000?mode=listener' --width 1280 --height 720
# Start it with: packager -c <this file> start
...
The file lists every setting with its default value, which makes it a complete
reference for that pipeline. To run it in a container, change [api] bind to
0.0.0.0:4041 and mount it at the default path:
docker run --rm -p 9000:9000/udp -v "$PWD/config.toml:/etc/packager/config.toml:ro" \
"$PACKAGER_IMAGE" start
From here you can add sinks, renditions or a compositor. Continue with How Packager works and the configuration reference.
Environment variables
Every flag except the switches (--ladder, --passthrough, --print-config) and the
repeatable options also reads an environment variable. This suits container
platforms that configure services through the environment:
| Flag | Environment variable |
|---|---|
--source | PACKAGER_SOURCE |
--sink | PACKAGER_SINK |
--sink-type | PACKAGER_SINK_TYPE |
--channel-id | PACKAGER_CHANNEL_ID |
--width, --height | PACKAGER_WIDTH, PACKAGER_HEIGHT |
--fps | PACKAGER_FPS |
--video-encoder | PACKAGER_VIDEO_ENCODER |
--test-signal-variant, --test-signal-title | PACKAGER_TEST_SIGNAL_VARIANT, PACKAGER_TEST_SIGNAL_TITLE |
--browser-url | PACKAGER_BROWSER_URL |
--api-bind | PACKAGER_API_BIND |
--log-level | PACKAGER_LOG_LEVEL |
docker run --rm \
-e PACKAGER_SOURCE=test-signal \
-e PACKAGER_SINK='rtmps://rtmp.global.cdn.vindral.com/publish/YOUR_STREAM_KEY' \
"$PACKAGER_IMAGE" start
An empty variable counts as unset. PACKAGER_SOURCE or PACKAGER_SINK selects
flag mode even when the default configuration file is present. With an explicit
-c/--config-file, startup fails with
--source/--sink build their own config; drop --config-file. The other pipeline variables
have no effect on a configuration-file start, so a leftover PACKAGER_WIDTH
cannot change one. --help does not print the values of --source and --sink,
which often contain a key.
Errors
A flag mistake stops Packager before anything starts, with exit status 2 and a single line on stderr:
| Message | Fix |
|---|---|
--source is neither test-signal, browser, a URL, nor an existing file | Check the spelling, or that the file is mounted in the container at that path. |
MoQ needs --channel-id | An http(s):// or ws(s):// sink is MoQ unless --sink-type vindral-ws is given. |
--ladder does not apply to RTMP: ffmpeg's FLV muxer takes one video stream | Use SRT or MoQ for a ladder. |
--ladder needs --width and --height for a network source, whose size is not known up front | Give the top rendition's size. |
--width and --height must be even and within 64..=8192 | Use even values in that range. |
--width must be even and within 320..=3840 for the test signal | The test signal accepts 320–3840 × 240–2160. |
--video-encoder … is not in this build's ffmpeg | Choose an encoder that the image includes. |
To combine several sources, publish to several destinations, mix audio or record,
write a configuration file. Starting from --print-config is the quickest way.