The Yale Astronomy Department is putting together a video showcasing some of the work going on in the department. All of the parts recently arrived for the Moletai Astronomical Observatory (MAO) Spectrograph that our group is building. The timing seems perfect, so the videographer in charge setup a couple cameras to capture the initial build of the spectrograph.

The photographer sent all of the stills in advance, and we couldn’t wait to see what the final time lapse would like, so I made a few time lapse videos myself using ffmpeg.

###Setting up ffmpeg

To put this together, I needed to install ffmpeg. This turned out to be a \ little challenging. I tried the normal homebrew install:

brew install ffmpeg

This worked! I then added a symbolic link to add it to my path:

cd /usr/local/bin
sudo ln -s /usr/local/Cellar/ffmpeg/2.5.3/bin/ffmpeg ffmpeg

Unfortunately, when I tried to get help on ffmpeg, here’s what it returned:

ffmpeg --help
dyld: Library not loaded: /usr/local/lib/libx264.142.dylib
  Referenced from: /usr/local/bin/ffmpeg
  Reason: image not found
Trace/BPT trap

I then did a search for this .dylib. homebrew installed it:

cd /usr/local/Cellar
find . -name libx264.142.dylib

I just needed to add it to my path:

cd /usr/local/bin
sudo ln -s /usr/local/Cellar/x264/r2495/lib/libx264.142.dylib libx264.142.dylib

I repeated this for a few more packages homebrew installed that were not in my path:

sudo ln -s /usr/local/Cellar/x264/r2495/lib/libx264.142.dylib libx264.142.dylib
sudo ln -s /usr/local/Cellar/libvo-aacenc/0.1.2/lib/libvo-aacenc.0.dylib libvo-aacenc.0.dylib
sudo ln -s /usr/local/Cellar/lame/3.99.5/lib/libmp3lame.0.dylib libmp3lame.0.dylib

Finally, ffmpeg -h returned the help, as expected.

I found this page on the ffmpeg wiki to be helpful in creating the time lapse. And Section 7.3 of the documentation too.

The files I wanted to add were stored in a folder named Bench-View_JPG. They were in sequential order, but they didn’t start at 0. The easiest way to add them all to the movie was the use the pattern_type optional argument in conjunction with glob. The other options I used were:

  • -framerate: the number of frames per second to input -r: the number of frames per second in the output video
  • s: the size of the output video

I wanted my video to be 1080p HD, and the final video to be called BenchMovie1080p11fps.mp4, so I used the following command:

ffmpeg -framerate 11 -pattern_type glob -i 'Bench-View_JPG/*.jpg' -r 11 -s 1620x1080 BenchMovie1080p11fps.mp4

The result can be seen below.

For embedding the video into the web page, I used the HTML5 <video> tag. I also set the width to “100%”” and the height to “auto” to make sure it was responsive and scaled properly. Here’s the code that made the above video:

<video width="100%" height="auto" controls>
  <source src="/images/BenchMovie1080p11fps.mp4" type="video/mp4">
Note: You are missing out on our time lapse video!
Upgrade your browser to one that supports the video tag.

The message, of course, only appears in unsupported browsers. Chrome, Firefox, Internet Explore, Opera, and Safari all support mp4 in the video tag.

The result is something that looks great on any browser and any device! I also created a time lapse video from stills taken with the other camera using the following command:

ffmpeg -framerate 11 -pattern_type glob -i 'Full-View_JPG/_CAM*.jpg' -r 11 -s 1620x1080 FullMovie1080p11fps.mp4

The results can be seen on MAO page of the Exoplanets Web Site.