Re-stream Twitch to Facebook Live

# Using read -s so you won't leak the stream key

# Verify that it's set by printing out the length of the key
echo ${#FB_STREAM_KEY}
  • Go live on twitch, then use youtube-dl to get stream url from twitch
TWITCH_STREAM_URL=$(youtube-dl -f best -g$TWITCH_USER)

  • Stream through facebook with ffmpeg
ffmpeg -i "$TWITCH_STREAM_URL" -c copy -f flv "rtmps://$FB_STREAM_KEY"

# Beware stream key leak if error occurred, so filter stream key out
ffmpeg -i "$TWITCH_STREAM_URL" -c copy -f flv "rtmps://$FB_STREAM_KEY" 2>&1 | sed "s/$FB_STREAM_KEY/$(printf '%*s' ${#FB_STREAM_KEY} | tr ' ' '*'))/g"
  • Wait for the video feed, then you can go live in Facebook