Created
December 11, 2014 18:16
-
-
Save deniska/ece0c87a10940a9710c3 to your computer and use it in GitHub Desktop.
Streaming to twitch using ffmpeg
This file contains hidden or 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 | |
WIDTH=1280 | |
HEIGHT=720 | |
XPOS=1500 | |
YPOS=200 | |
read KEY < ~/.twitch_key | |
URL="rtmp://live-prg.twitch.tv/app/$KEY" | |
#URL="test.flv" | |
function stream { | |
ffmpeg \ | |
-f pulse -ac 2 -ar 44100 -i alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor \ | |
-f pulse -ac 2 -ar 44100 -i alsa_input.pci-0000_00_1b.0.analog-stereo \ | |
-filter_complex amix=inputs=2 \ | |
-f x11grab -r 30 -s "$WIDTH"x"$HEIGHT" -i :0.0+$XPOS,$YPOS \ | |
-vcodec libx264 -preset fast -maxrate 2000 \ | |
-acodec libmp3lame -ar 44100 -q:a 1 \ | |
-pix_fmt yuv420p -loglevel error -f flv "$URL" | |
} | |
case $1 in | |
"resize") | |
xdotool getactivewindow windowmove $XPOS $YPOS \ | |
windowsize $WIDTH $HEIGHT | |
;; | |
"center") | |
WINWIDTH=$(xwininfo -id $(xdotool getactivewindow) \ | |
| awk '/Width/ {print($2)}') | |
WINHEIGHT=$(xwininfo -id $(xdotool getactivewindow) \ | |
| awk '/Height/ {print($2)}') | |
xdotool getactivewindow windowmove \ | |
$(( XPOS + (WIDTH - WINWIDTH) / 2 )) \ | |
$(( YPOS + (HEIGHT - WINHEIGHT) / 2 )) | |
;; | |
"stream") | |
stream | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment