Skip to content

Commit 528ca2b

Browse files
authored
box: Allow specifying custom input video (#3731)
* box: Allow changing input video FPS * box: Allow specifying input video to stream
1 parent 4a2774a commit 528ca2b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

box/stream.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PIPELINE=${PIPELINE:-noop}
55
STREAM_KEY="my-stream"
66
STREAM_ID="my-stream-id"
77
RTMP_OUTPUT=${RTMP_OUTPUT:-""}
8+
FPS=${FPS:-30}
9+
INPUT_VIDEO=${INPUT_VIDEO:-""}
810

911
case "$1" in
1012
start)
@@ -18,12 +20,16 @@ case "$1" in
1820
QUERY="${QUERY}\&params=${ENCODED_PARAMS}"
1921
fi
2022

21-
ffmpeg -re -f lavfi \
22-
-i testsrc=size=1920x1080:rate=30,format=yuv420p \
23-
-vf scale=1280:720 \
23+
INPUT_FLAGS="-f lavfi -i testsrc=size=1280x720:rate=${FPS},format=yuv420p"
24+
if [ -n "$INPUT_VIDEO" ]; then
25+
INPUT_FLAGS="-stream_loop -1 -i ${INPUT_VIDEO}"
26+
fi
27+
28+
ffmpeg -re ${INPUT_FLAGS} \
29+
-vf "scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720" \
2430
-c:v libx264 \
2531
-b:v 1000k \
26-
-x264-params keyint=60 \
32+
-x264-params keyint=$((FPS * 2)) \
2733
-f flv rtmp://127.0.0.1:1935/${STREAM_KEY}?${QUERY}
2834
;;
2935
playback)

0 commit comments

Comments
 (0)