Created
December 21, 2024 23:43
-
-
Save mmuman/f30855d57babd42f05091f6192d30722 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 | |
#LISTEN_URL='rtmp://localhost:1935/live/app' | |
LISTEN_URL='rtmp://127.0.0.1:1935/live/app' | |
TWITCH_LIVE_SERVER="live-fra" | |
CONFIG_PATH="$HOME/.config/obs-studio" | |
TWITCH_KEY_F="$CONFIG_PATH/twitch.key" | |
YOUTUBE_KEY_F="$CONFIG_PATH/youtube.key" | |
PEERTUBE_KEY_F="$CONFIG_PATH/peertube.key" | |
TEE="" | |
if [ -e $TWITCH_KEY_F ]; then | |
TWITCH_KEY="$(cat "$TWITCH_KEY_F")" | |
# Note: Twitch wants a keyframe every 2s: | |
# https://ubuntuforums.org/archive/index.php/t-2230883.html | |
TWITCH_URL="rtmp://$TWITCH_LIVE_SERVER.twitch.tv/app/$TWITCH_KEY" | |
TEE="$TEE[f=flv]$TWITCH_URL|" | |
fi | |
#TODO | |
if [ -e "$YOUTUBE_KEY_F" ]; then | |
YOUTUBE_KEY="$(cat "$YOUTUBE_KEY_F")" | |
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2/$YOUTUBE_KEY" | |
#backup: rtmp://b.rtmp.youtube.com/live2?backup=1 | |
TEE="$TEE[f=flv]$YOUTUBE_URL|" | |
fi | |
#TODO | |
if [ -e "$PEERTUBE_KEY_F" ]; then | |
PEERTUBE_KEY="$(cat "$PEERTUBE_KEY_F")" | |
PEERTUBE_URL="rtmp://a.rtmp.youtube.com/live2/$PEERTUBE_KEY" | |
TEE="$TEE[f=flv]$PEERTUBE_URL|" | |
fi | |
TEE="${TEE%|}" | |
echo "$TEE" | |
#exit 1 | |
# cf. | |
# https://obsproject.com/forum/resources/obs-studio-stream-to-multiple-platforms-or-channels-at-once.932/ | |
# https://video.stackexchange.com/questions/26257/rtmp-server-using-ffmpeg | |
exec ffmpeg -re \ | |
-f flv -listen 1 -i "$LISTEN_URL" \ | |
-c:v copy -c:a copy -map 0 -f tee \ | |
"$TEE" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment