moq-rs/dev/pub

33 lines
852 B
Plaintext
Raw Normal View History

#!/bin/bash
set -euo pipefail
# Change directory to the root of the project
cd "$(dirname "$0")/.."
export RUST_LOG="${RUST_LOG:-info}"
# Connect to localhost by default.
HOST="${HOST:-localhost}"
PORT="${PORT:-4443}"
ADDR="${ADDR:-$HOST:$PORT}"
# Generate a random 16 character name by default.
NAME="${NAME:-$(head /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 16)}"
# Combine the host and name into a URL.
URL="${URL:-"https://$ADDR/$NAME"}"
# Default to a source video
MEDIA="${MEDIA:-dev/source.mp4}"
# Print out the watch URL
echo "Watch URL: https://quic.video/watch/$NAME?server=$ADDR"
# Run ffmpeg and pipe the output to moq-pub
ffmpeg -hide_banner -v quiet \
-stream_loop -1 -re \
-i "$MEDIA" \
-an \
-f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - \
2023-10-13 14:43:29 +00:00
| cargo run --bin moq-pub -- "$URL" "$@"