Skip to content

Instantly share code, notes, and snippets.

@wbbradley
Created February 17, 2014 00:10
Show Gist options
  • Save wbbradley/9042509 to your computer and use it in GitHub Desktop.
Save wbbradley/9042509 to your computer and use it in GitHub Desktop.
A little script that uses Mac OS X's screencapture, ImageMagick and ffmpeg to capture a bunch of screenshots with instructions for making an MPEG movie
#!/usr/bin/python
import os
import sys
import time
from datetime import datetime
from AppKit import NSWorkspace
# This will be a movie
process_filter = None
if len(sys.argv) >= 2:
process_filter = sys.argv[1]
if len(sys.argv) >= 3:
sleep_time = int(sys.argv[2])
print 'try: convert -quality 100 snapshot-*.png outvideo.mpeg'
print 'then: rm snapshot-*.png'
print 'when you want to stop recording: Ctrl-C'
while True:
time.sleep(5)
active_app_name = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']
if process_filter and active_app_name.lower().find(process_filter) == -1:
continue
filename = 'snapshot-{}'.format(datetime.now().strftime('%Y-%m-%d-%H-%M-%S.%f.png'))
# print 'Capturing screen because {} is the active application. {}'.format(active_app_name, process_filter)
os.system('screencapture -mxrC {}'.format(filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment