-
-
Save sophiabrandt/d857ae580a0020ec321f 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 | |
# modified script for streaming on Linux via ffmpeg. | |
# Original see here: https://gist.github.com/oseparovic/2db2aaa737cd37e7c068 | |
# see http://ubuntuguide.org/wiki/Screencasts for full documentation | |
# see http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/ | |
# for instructions on how to use this gist | |
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 | |
# input resolution, set it manually in the format "WIDTHxHEIGHT" instead. | |
INRES="1920x1080" | |
# output resolution. | |
# keep the aspect ratio the same or your stream will not fill the display. | |
OUTRES="800x600" | |
# input audio. You can use "/dev/dsp" for your primary audio input. | |
INAUD="pulse" | |
# target fps | |
FPS="30" | |
# video preset quality level. | |
# more FFMPEG presets available in /usr/share/ffmpeg | |
# According to trac.ffmpeg.org/wiki/x264EncodingGuide the presets are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, | |
# veryslow, placebo | |
QUAL="fast" | |
# stream key. You can set this manually, or reference it from a hidden file like what is done here. | |
STREAM_KEY=$(cat ~/.twitch_key) | |
# stream url. Note the formats for twitch.tv and justin.tv | |
# twitch:"rtmp://live.twitch.tv/app/$STREAM_KEY" | |
# justin:"rtmp://live.justin.tv/app/$STREAM_KEY" | |
STREAM_URL="rtmp://live.twitch.tv/app/$STREAM_KEY" | |
ffmpeg \ | |
-f alsa -ac 2 -i "$INAUD" \ | |
-f x11grab -s "$INRES" -r "$FPS" -i :0.0 \ | |
-vcodec libx264 -pix_fmt yuv420p -s "$OUTRES" -preset "$QUAL" -g 2 \ | |
-acodec libmp3lame -threads 6 -b:a 128KB \ | |
-f flv -ar 44100 "$STREAM_URL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment