Skip to content

Instantly share code, notes, and snippets.

@gaganpreet
Created June 16, 2012 04:00
Show Gist options
  • Save gaganpreet/2939850 to your computer and use it in GitHub Desktop.
Save gaganpreet/2939850 to your computer and use it in GitHub Desktop.
Twitch.tv stream with webcam overlay/pip
#!/bin/sh -xe
INFO=$(xwininfo -frame)
API_KEY="KEY"
WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+')
WIN_XY=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' )
FPS="15"
INRES='640x480'
OUTRES='320x240'
ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0+$WIN_XY \
-f alsa -ac 2 -i default -vcodec libx264 -s "$OUTRES" \
-acodec libmp3lame -ab 128k -ar 44100 -threads 0 \
-vf "movie=/dev/video0:f=video4linux2, scale=120:-1, setpts=PTS-STARTPTS [movie];[in] setpts=PTS-STARTPTS, [movie] overlay=main_w-overlay_w:main_h-overlay_h [out]" \
-f flv "rtmp://live.twitch.tv/app/$API_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment