Skip to content

Instantly share code, notes, and snippets.

@woudsma
Last active September 17, 2019 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woudsma/7f57a307bb4e841715297ed24ecbcaa2 to your computer and use it in GitHub Desktop.
Save woudsma/7f57a307bb4e841715297ed24ecbcaa2 to your computer and use it in GitHub Desktop.
static video to realtime live stream to twitch with ffmpeg - quick n dirty
# Quick and dirty script for streaming a video file to Twitch (as if it were live)
# Requirements: ffmpeg (http://www.ffmpeg.org)
# Copy-paste the function and call it in your command line
# Or add the function to ~/.bash_profile, ~/.zshrc, ..etc.
# Usage:
# twitch STREAM_KEY FILEPATH
# Example:
# twitch live_122343457_TxVALrandomstuffA1ADt /Users/woudsma/Music/streams/recording.mp4
twitch() {
echo "Usage: twitch STREAM_KEY FILEPATH"
STREAM_KEY="$1"
SERVER="live-ams" # twitch server in frankfurt, see http://bashtech.net/twitch/ingest.php for list
ffmpeg -re -i "$2" \
-vcodec copy \
-acodec libmp3lame -ar 44100 -threads 2 -b:a 128k -bufsize 2048k \
-f flv "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment