Created
July 12, 2024 13:04
-
-
Save secemp9/8c15bdb010617904e45ff94cee9a63ee to your computer and use it in GitHub Desktop.
Stream test
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 | |
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2/KEY" | |
TWITTER_URL="rtmp://va.pscp.tv:80/x/KEY" | |
TWITCH_URL="rtmp://live.twitch.tv/app/KEY" | |
YOUTUBE_BITRATE="9M" | |
TWITTER_BITRATE="9M" | |
TWITCH_BITRATE="7M" | |
LOCAL_RTMP="rtmp://0.0.0.0:1935" | |
SOCKET_PATH="/tmp/live_stream.sock" | |
ffmpeg -listen 1 -i "$LOCAL_RTMP" -c copy -f mpegts "unix:$SOCKET_PATH" & | |
start_output() { | |
local platform=$1 | |
local url=$2 | |
local bitrate=$3 | |
while true; do | |
ffmpeg -i "unix:$SOCKET_PATH" \ | |
-c:v libx264 -preset veryfast -tune zerolatency \ | |
-b:v "$bitrate" -maxrate "$bitrate" -bufsize 3000k \ | |
-g 60 -flags +global_header \ | |
-c:a copy \ | |
-f flv "$url" | |
echo "Restarting $platform stream..." | |
sleep 5 | |
done | |
} | |
start_output "YouTube" "$YOUTUBE_URL" "$YOUTUBE_BITRATE" & | |
start_output "Twitter" "$TWITTER_URL" "$TWITTER_BITRATE" & | |
start_output "Twitch" "$TWITCH_URL" "$TWITCH_BITRATE" & | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment