How to Create a Time Lapse Video using FFMPEG
July 5th, 2007 by Andrew WellsSince I just got my TV tuner card less then a week ago, I have been learning a thing or two on some video file manipulation. Creating a time lapse was something I wanted to create from my storm chasing video, and this was how I did it.
The shell script below should be saved as time-lapse.sh if you decide to save it. The script must take three (3) parameters. The first one is the input file. The second one is the output file, and the third is the framerate. The lower the framerate, the faster the time lapse. Line 10 takes every ‘n’ frames per second from the video and saves them in a temporary folder in png format. Then, line 11 takes those png images, and converts it back into a video – without sound, and sped up. Easy, yes?
1 2 3 4 5 6 7 8 9 10 11 12 | #!/bin/bash # Description: make time lapse video # Usage: time-lapse.sh <source-video> <destination-file> <frames> # Source Video: the video that you are wanting to speed up # Destination File: the file where the video will be saved # Frames: the number of frames to pull per second (1 will speed it up the most, 10 will be slower) mkdir ffmpeg_temp ffmpeg -i $1 -r $3 -f image2 ffmpeg_temp/%05d.png ffmpeg -i ffmpeg_temp/%05d.png -b 512 $2 rm -rf ./ffmpeg_temp |
I am working on a Nautilus script, so it can show up in a popup menu, but I don’t have that mastered as of yet, so stay tuned. I will post it later.
October 18th, 2007 at 1:03 am
Cripes! I can’t believe how difficult it is to do something so trivial as turn a 30 minute video into a 1 minute video.
I should have remembered ffmpeg from my past while backing up security camera footage at my day job. I should have known that a Linux solution would come to save the day.
I paid $100 for a piece of windows software (Roxio Easy Media Creator 10) that I assumed would do such a stupifyingly simple task as time-lapse video, but it did not. After much google/searching, the only capable purchasable product I found was the Mac/Apple products ($500+).
Thank god for ffmpeg, and that pr0gr4mm3r (Andrew Wells) published this simple how-to on the subject.
One note about this script. Do not specify .AVI as the output as ffmpeg chooses a codec that windows media player will not play. Be sure to choose .MPG as the output file when running this script.
Here is the error message received when choosing .AVI as the output.
“Windows Media Player cannot play the file. The Player might not support the file type or a required codec might not be installed on your computer.”
Great work Andrew Wells!
Thank You
Hack Hawk aka Tech Druid aka Richard
October 23rd, 2007 at 7:03 pm
I was not able to find a solution in Windows myself. Thanks for your tip on converting to .avi. I usually just use mpegs because that’s what my TV tuner uses by default.
January 5th, 2008 at 10:20 pm
[...] This post was a variation on my tutorial on creating a time lapse video using FFMPEG. [...]
July 12th, 2008 at 6:51 pm
Thanks! In addition to the time lapse, I was also able to modify your script to reverse a video, which is another effect I hadn’t found elsewhere.
July 12th, 2008 at 7:00 pm
Awesome. What did you do to reverse the video?