Created
February 17, 2014 00:10
-
-
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
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
#!/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