Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created May 5, 2015 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myokoym/f417d222abc4b6dfc55e to your computer and use it in GitHub Desktop.
Save myokoym/f417d222abc4b6dfc55e to your computer and use it in GitHub Desktop.
Capture a terminal to FLV video using FFmpeg on Debian GNU/Linux.
#!/usr/bin/env ruby
output_path = "#{ARGV[0] || "out"}.flv"
info = `xwininfo -id $(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | grep -Eo "0x[0-9a-f]{2,}")`
x = info.scan(/Absolute upper-left X: *(\d+)/).first.last.to_i
y = info.scan(/Absolute upper-left Y: *(\d+)/).first.last.to_i
width = info.scan(/Width: *(\d+)/).first.last.to_i
height = info.scan(/Height: *(\d+)/).first.last.to_i
system("ffmpeg -r 10 -s #{width},#{height} -f x11grab -i :0.0+#{x},#{y} -f alsa -i default -an -vcodec libx264 -b 400k -threads 4 -vsync 1 -y -f flv #{output_path}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment