Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions box/box.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ export RTMP_OUTPUT=rtmp://rtmp.livepeer.com/live/$STREAM_KEY

This one is only required for the `box-stream` command. It is useful when you cannot use the `box-playback` command to play the stream, for example when you are using a remote non-UI machine.

### Video Input

By default, `box-stream` uses a generated test pattern. You can use a video file or webcam instead:

```bash
# Use a video file
export INPUT_VIDEO=/path/to/video.mp4

# Or use a webcam (Linux)
export INPUT_WEBCAM=/dev/video0
```

### Docker
If you want to run the box in a docker container, set the `DOCKER` env var:
```bash
Expand Down
6 changes: 3 additions & 3 deletions box/box.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ set -e
DOCKER=${DOCKER:-false}
FRONTEND=${FRONTEND:-false}

if [ "$FRONTEND" = "true" && "$DOCKER" = "false" ]; then
if [[ "$FRONTEND" = "true" && "$DOCKER" = "false" ]]; then
echo "Running the box with FRONTEND=true requires DOCKER=true"
exit 1
fi

# Ensure backgrounded services are stopped gracefully when this script is interrupted or exits.
cleanup() {
if [ "$DOCKER" = "true" ]; then
if [[ "$DOCKER" = "true" ]]; then
echo "Stopping dockerized services..."
docker stop orchestrator --time 15 >/dev/null 2>&1 || true
docker stop gateway --time 15 >/dev/null 2>&1 || true
Expand Down Expand Up @@ -51,7 +51,7 @@ gateway &
orchestrator &
mediamtx &

if [ "$FRONTEND" = "true" ]; then
if [[ "$FRONTEND" = "true" ]]; then
supabase &
frontend &
fi
Expand Down
5 changes: 5 additions & 0 deletions box/stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ STREAM_ID="my-stream-id"
RTMP_OUTPUT=${RTMP_OUTPUT:-""}
FPS=${FPS:-30}
INPUT_VIDEO=${INPUT_VIDEO:-""}
INPUT_WEBCAM=${INPUT_WEBCAM:-""}

case "$1" in
start)
Expand All @@ -22,7 +23,11 @@ case "$1" in

INPUT_FLAGS="-f lavfi -i testsrc=size=1280x720:rate=${FPS},format=yuv420p"
if [ -n "$INPUT_VIDEO" ]; then
echo "Using video file: ${INPUT_VIDEO}"
INPUT_FLAGS="-stream_loop -1 -i ${INPUT_VIDEO}"
elif [ -n "$INPUT_WEBCAM" ]; then
echo "Using webcam: ${INPUT_WEBCAM}"
INPUT_FLAGS="-f v4l2 -framerate ${FPS} -video_size 1280x720 -i ${INPUT_WEBCAM}"
fi

ffmpeg -re ${INPUT_FLAGS} \
Expand Down
Loading