Skip to content

Instantly share code, notes, and snippets.

@lifning
Created November 25, 2012 10:11
Show Gist options
  • Save lifning/4142976 to your computer and use it in GitHub Desktop.
Save lifning/4142976 to your computer and use it in GitHub Desktop.
Scripts for streaming to twitch.tv on Linux.
#!/bin/bash
JTV_STREAM_KEY=$(cat ~/Dropbox/jtv-key)
JTV_STREAM_URL=rtmp://live.justin.tv/app/${JTV_STREAM_KEY}
exec glc-capture --disable-audio -f 30 -z none -o /dev/stdout -s "${@}" \
| glc-play /dev/stdin -y 1 -o /dev/stdout \
| ffmpeg \
-f yuv4mpegpipe -i /dev/stdin \
-f pulse -itsoffset 0.2 -sample_rate 22050 -i default \
-f flv -vcodec libx264 -vf "scale=-1:360" -r 30 \
${JTV_STREAM_URL}
#!/bin/bash
JTV_STREAM_KEY=$(cat ~/Dropbox/jtv-key)
JTV_STREAM_URL=rtmp://live.justin.tv/app/${JTV_STREAM_KEY}
zenity --info --text='Click OK, then click the window you want to stream.'
XINFO=$(xwininfo -stats)
X=$(echo "${XINFO}" | fgrep 'Absolute upper-left X:' | awk '{print $4}')
Y=$(echo "${XINFO}" | fgrep 'Absolute upper-left Y:' | awk '{print $4}')
W=$(echo "${XINFO}" | fgrep Width | awk '{print $2}')
H=$(echo "${XINFO}" | fgrep Height | awk '{print $2}')
exec ffmpeg \
-f x11grab -s ${W}x${H} -r 15 -i :0.0+${X},${Y}+${W}x${H} \
-f pulse -sample_rate 22050 -i default \
-f flv -vcodec libx264 -vf "scale=-1:360" -pix_fmt yuv420p -r 15 \
${JTV_STREAM_URL}
@maitre
Copy link

maitre commented Apr 12, 2015

Intriguing approach to this solution. I shall be interested to try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment