Files
ac-ms-media-transcode/bin/fanout-copy.sh
Anton Afanasyeu 5ca8a9f539 Add lab restream pipeline with pirate_drift logo and lib/env.sh.
Encode-once/fanout scripts, HLS output, and single overloadable env source.
Commits assets/pirate_drift.png as default watermark for cluster runs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 15:27:24 +02:00

37 lines
979 B
Bash
Executable File

#!/usr/bin/env bash
# Fan-out: read pre-encoded FLV from pipe → RTMP sinks (stream copy, no re-encode).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck disable=SC1091
source "${ROOT}/lib/common.sh"
# shellcheck disable=SC1091
source "${ROOT}/lib/outputs.sh"
require_cmd "${FFMPEG_BIN}"
ensure_storage
ensure_pipe
TEE_SPEC="$(build_fanout_tee_spec)"
LOG_FILE="${STORAGE_DIR}/fanout.log"
MAX_RETRIES="${FANOUT_RETRIES:-5}"
attempt=0
log "fanout → ${#SINKS[@]} sink(s)"
while [[ "${attempt}" -le "${MAX_RETRIES}" ]]; do
attempt=$((attempt + 1))
log "fanout attempt ${attempt}/${MAX_RETRIES}"
if "${FFMPEG_BIN}" -hide_banner -loglevel info \
-thread_queue_size "${THREAD_QUEUE_SIZE}" \
-i "${PIPE_PATH}" \
-map 0 \
-c copy \
-f tee "${TEE_SPEC}" >> "${LOG_FILE}" 2>&1; then
log "fanout finished normally"
break
fi
warn "fanout ffmpeg exited — retrying after pipe flush"
sleep 1
done