# Maniac Technical Instructions

Nick Winter originally did this with Telepath Logger. Bethany managed to get that working for her maniac week and helped Danny get it working on his computer but it involved hacking on the actual code and we wanted to experiment with a setup that anyone could use. Also, we wanted to do things like tail our TagTime log files in the dashboard area (aka HUD). So, with ideas from Lawrence Evalyn, here’s how we did it:

## Collecting the screenshots

Here are things we’ve tried:

1. Set up InstantShot (Mac OSX) to take a screenshot every minute and store them to a specified directory.
2. Similar thing by Aaron Parecki that stores screenshots every 30 seconds, for up to 2 monitors, in ~/Pictures/Maniac: https://github.com/aaronpk/Maniac-Clock/releases
3. For nerds comfortable with cron and shell scripts, we now think something like screencap.sh is most robust but that needs adapting for maniac timelapse purposes (also it wants put in GitHub!).

## Collecting the webcam footage

Instead of trying to capture a separate video from your webcam and splice it together, just leave a small window with a live-updating image from your webcam at the bottom of the screen and let the screenshots capture it. You could do that by just opening some app that shows a live preview like Photobooth (except it won’t resize small enough) or Quicktime recorder (but the control buttons cover up the bottom of your face) or Gawker, but probably you’ll want something better. Here are things we’ve tried:

• https://github.com/fredantell/electron-webcam (add flip_horiz: true to line 6 of renderer.js)
• Mathematica:
CreateDialog[Dynamic[ImageResize[ImageReflect[ImageCrop[CurrentImage[], {320/2, 240/2}, {Center,Top}], Left], 320], None, UpdateInterval->Infinity, SynchronousUpdating->False], WindowTitle->"I'm a maniac"]

## Turning the directory full of images into a video

Lawrence Evalyn says he got the images turned into a video using iMovie but now he and dreeves recommend Zeitraffer which works like a charm for any amount of images.

If you want to automate the process, read on for uebernerd hackery from Bethany with ffmpeg:

1. In your images directory, crop all the images and write them to numbered imgXXXXX.jpg files in a subdirectory called tmp:
x=1; for i in *.jpg; do counter=$(printf %05d$x); convert -crop 5120x3200+0+0 $i tmp/img"$counter".jpg; x=$(($x+1)); done

2. Or if you just need to name them to have consecutive numbers in the filename:
mkdir tmp
x=1; for i in *.jpg; do counter=$(printf %05d$x); cp $i tmp/img"$counter".jpg; x=$(($x+1)); done

3. Make a movie out of the images in tmp/ with 30 frames per second. Write it to maniac.mp4:
ffmpeg -r 30 -f image2 -i tmp/img%05d.jpg -y -s 2560x1600 -r 30 -vcodec libx264 -preset slower -tune stillimage -crf 18 maniac.mp4

Easiest is to drag and drop the video and audio into iMovie and let it upload the result straight to YouTube.

If you want to do it from the command line, more from Bethany…

Find a soundtrack as an m4a file and run this:
ffmpeg -i maniac.mp4 -i somesong.m4a -c:v copy -c:a copy -map 0:0 -map 1:0 -map 1:0 maniac_with_soundtrack.mp4
If the sound file is longer than the video then add “-shortest” before maniac_with_soundtrack.mp4 to have the soundtrack cut out when the timelapse ends.

(Bethany had issues with this that turned out to have to do with the encoding of the music. When she edited together a soundtrack in audacity and exported with an ffmpeg compatible filetype it worked fine.)

## Maniacal Tips

2. Lawrence has an awesome segment in his timelapse where he pointed his webcam out the window and you can watch the clouds rolling by.

## Maniac Checklist

1. Turn off screen saver
2. Finish this checklist

## Other Goodies

Bethany also made this for showing the time and day:

http://time.glitch.me

The idea is to put it in a browser window shrunk down so it fits in your dashboard area. It’s worth having something dynamic like this in your dashboard otherwise there’s nothing interesting to see in the timelapse when you’re asleep. If you don’t want to count on an internet connection just grab the page source and put it an html file and open it that way.