Files
v10/apps/sandbox/scripts/live/broadcast.sh
T
Christian PillsburyandClaude Opus 4.8 da33b10952 test(sandbox): add ffmpeg + Mux live/DVR test-stream scripts and orchestrator
apps/sandbox/scripts/live/ — spin up an ephemeral Mux live source for
exercising the live path in any HLS-capable sandbox page:
- create-stream.sh: create a low-latency Mux live stream (creds via
  --token-id/--token-secret flags or MUX_TOKEN_ID/MUX_TOKEN_SECRET env;
  --quiet for scripting)
- broadcast.sh: push an ffmpeg testsrc + tone feed to the stream
- dvr-url.sh: resolve active_asset_id to the DVR/EVENT playback URL
- live-test.sh: orchestrate create -> broadcast -> wait -> open the page,
  parameterized by --page (renderer-agnostic), --flavor sliding|dvr|both,
  --port, --params, --latency; deletes the stream on exit unless --keep
- README.md: quick-start, manual steps, and cross-renderer reuse notes

Credentials are read only from flags/env; none are committed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 13:52:21 -07:00

26 lines
977 B
Bash
Executable File

#!/usr/bin/env bash
# Push an ffmpeg-generated test feed (color bars + 440 Hz tone) to a Mux live
# stream. Run in its own terminal; Ctrl-C to stop. Mux turns this into both a
# sliding-window live playlist and (because the stream records) a growing
# DVR / EVENT playlist.
#
# Usage: ./broadcast.sh <STREAM_KEY>
# STREAM_KEY is printed by create-stream.sh.
set -euo pipefail
key="${1:-}"
if [ -z "$key" ]; then
echo "Usage: $0 <STREAM_KEY> (the stream key printed by create-stream.sh)" >&2
exit 1
fi
# -re paces input at real time; zerolatency + short GOP keep segments small for
# low-latency live. CMAF/fMP4 output is what the SPF MSE pipeline appends.
exec ffmpeg -re \
-f lavfi -i "testsrc=size=1280x720:rate=30" \
-f lavfi -i "sine=frequency=440:sample_rate=48000" \
-c:v libx264 -preset veryfast -tune zerolatency -g 60 -keyint_min 60 \
-b:v 2500k -pix_fmt yuv420p \
-c:a aac -b:a 128k -ar 48000 \
-f flv "rtmps://global-live.mux.com:443/app/$key"