-
-
Save ayr-ton/f39a75786581dd0f49bfb0f599021e9a 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 | |
# Inspired on: | |
# http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/ | |
# https://wiki.archlinux.org/index.php/Streaming_to_twitch.tv | |
if [ ! -f ~/.twitch_key ]; then | |
echo "Error: Could not find file: ~/.twitch_key" | |
echo "Please create this file and copy past your stream key into it. Open this script for more details." | |
exit 1; | |
fi | |
INRES="1920x1080" # input resolution | |
OUTRES="1920x1080" # output resolution | |
FPS="15" # target FPS | |
GOP="30" # i-frame interval, should be double of FPS, | |
GOPMIN="15" # min i-frame interval, should be equal to fps, | |
THREADS="2" # max 6 | |
CBR="1000k" # constant bitrate (should be between 1000k - 3000k) | |
QUALITY="ultrafast" # one of the many FFMPEG preset | |
AUDIO_RATE="44100" | |
STREAM_KEY=$(cat ~/.twitch_key) | |
SERVER="live-fra" # twitch server in frankfurt, see http://bashtech.net/twitch/ingest.php for list | |
ffmpeg -f x11grab \ | |
-s "$INRES" \ | |
-r "$FPS" \ | |
-i :0.0 \ | |
-f alsa -i pulse \ | |
-f flv -ac 2 \ | |
-ar $AUDIO_RATE \ | |
-vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv420p\ | |
-s $OUTRES -preset $QUALITY -tune film -acodec libmp3lame -threads $THREADS -strict normal \ | |
-bufsize $CBR "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