Jpg images to a movie
This is another post where I’m recording how I did something so that I can repeat again in the future.
Over the weekend, I used reclaimed materials to make a hanging animal feeder where we could put our stale snack foods instead of throwing them out. We also had an unused motion sensor camera sitting around (because who doesn’t?), so I set it up to see what was actually feeding from our new contraption. We figured it would be crows, but it turns out to be squirrels….. and rats! (Though kind of cute pet-rat like things, rather than a Bostonian Master Splinter.)
Thus, I was left with ~80 images of a rat hanging out on the feeder, and another ~55 of a squirrel. I wanted to turn this into a movie (to be shared by various media), but wanted to go back to using readily accessible command line tools, rather than some kind of shareware-ilke computer program I’d have to download and use (with advertisements and/ or limitations). After a while, I figured it out, so here are the steps for the next time I want to do it.
# Install ffmpeg using homebrew.
$ brew install ffmpeg
# After going to the directory with the files, a single line of code to make the movie.
$ ffmpeg -f image2 -r 5 -i STC_%*.JPG -c:v libx264 -pix_fmt yuv420p Rat2.mp4
This is what some of the stuff means:
“-r 5” : sets the frame-rate (5 images per second)
“STC_%*.JPG” : this is the naming pattern to gather all the files I want to turn into a movie. For example, the names of the files I had ranged (non-sequentially) from “STC_0125.JPG”, “STC_0140.JPG”, … , “STC_0285.JPG”.
“-c:v libx264” : video codec (same as MPEG4/H.264)
“-pix_fmt yuv420p” : pixel color format (I think this is needed for it to work properly on OSX)
“Rat2.mp4” : this is the output file name
Huzzah. Now nothing can stop me from doing some… claymation.
Sources that helped me a lot: