Created
November 27, 2022 14:18
-
-
Save andrewmackrodt/88c2233fb9cc4797ada93e6703c13d72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function finish { | |
if [[ "${rtspContainerId:-}" != "" ]]; then | |
docker kill "$rtspContainerId" | |
fi | |
if [[ "${ffmpegPid:-}" != "" ]]; then | |
kill "$ffmpegPid" | |
fi | |
} | |
trap finish EXIT | |
rtspContainerId=$( \ | |
docker run --rm -it -d \ | |
-e RTSP_PROTOCOLS=tcp \ | |
-p 8554:8554 \ | |
aler9/rtsp-simple-server \ | |
) | |
while true; do | |
if nc -w1 127.0.0.1 8554; then | |
break | |
fi | |
done | |
resolution=$(xrandr | awk '$2 == "connected" && $3 == "primary" { print $4 }' | sed -E 's/\+.+//') | |
ffmpeg -f x11grab -i ${DISPLAY:-:0} -video_size "$resolution" \ | |
-framerate 30 \ | |
-vcodec libx264 \ | |
-tune zerolatency \ | |
-crf 18 \ | |
-b:v 500k \ | |
-bufsize 300k \ | |
-vf scale=1280:-1 \ | |
-f rtsp \ | |
-rtsp_transport tcp \ | |
rtsp://127.0.0.1:8554/stream & | |
ffmpegPid=$? | |
docker logs -f "$rtspContainerId" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment