Created
November 15, 2014 14:39
-
-
Save danielkza/1c97d6db633fa85186ca 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/sh | |
CONFIG_FILE="$HOME/.config/twitchstreamrc" | |
if ! [ -f "$CONFIG_FILE" ]; then | |
echo "Missing configuration file ('$CONFIG_FILE')" 1>&2 | |
exit 1 | |
fi | |
. "$CONFIG_FILE" | |
GOP=$(( $FPS * 2 )) | |
GOPMIN=$FPS | |
THREAD_PARAMS="" | |
if [ -n "$THREADS" ]; then | |
THREAD_PARAMS="-threads \"$THREADS\"" | |
fi | |
stream_fifo='/tmp/twitch-stream-fifo' | |
if ! [ -e "$stream_fifo" ]; then | |
mkfifo "$stream_fifo" || exit 1 | |
fi | |
ffmpeg \ | |
-f x11grab \ | |
-video_size "$INRES" \ | |
-framerate "$FPS" \ | |
-i :0.0 \ | |
-f pulse \ | |
-i default \ | |
-f flv \ | |
-vcodec libx264 \ | |
-pix_fmt +yuv420p \ | |
-g "$GOP" \ | |
-keyint_min "$GOPMIN" \ | |
-b:v "$VIDEO_BITRATE" \ | |
-bufsize "$VIDEO_BITRATE" \ | |
-minrate "$VIDEO_BITRATE" \ | |
-maxrate "$VIDEO_BITRATE" \ | |
-s "$OUTRES" \ | |
-preset "$QUALITY" \ | |
-tune film \ | |
-acodec aac \ | |
-ac 2 \ | |
-ar "$AUDIO_SAMPLE_RATE" \ | |
-b:a "$AUDIO_BITRATE" \ | |
$THREAD_PARAMS \ | |
-strict experimental \ | |
"rtmp://$SERVER.twitch.tv/app/$STREAM_KEY" | |
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
# input resolution | |
INRES=1920x1080 | |
# output resolution | |
OUTRES=1920x1080 | |
# target FPS | |
FPS=60 | |
# number of threads (empty for automatic) | |
THREADS= | |
# constant bitrate (should be between 1000k - 3000k) | |
VIDEO_BITRATE=2500k | |
# one of the many FFMPEG preset | |
QUALITY=veryfast | |
# audio sampling rate | |
AUDIO_SAMPLE_RATE=48000 | |
# audio bitrate | |
AUDIO_BITRATE=160k | |
# use the terminal command Streaming streamkeyhere to stream your video to twitch or justin | |
STREAM_KEY='your_key' | |
# twitch server in frankfurt, see http://bashtech.net/twitch/ingest.php for list | |
SERVER=live |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment