Time lapse movies from still jpegs

Commercial user software discussion.

Time lapse movies from still jpegs

Postby Doug Coulter » Thu Jan 21, 2016 9:32 pm

I'm posting this because in some situations the easy-to-find web answers don't work.
This is in part because some versions of linux don't do ffmpeg anymore, due to an acrimonious fork to libav, and putting ffmpeg into say, ubuntu 14.04 breaks other things...(I use Mint Mate 17.3 which is ubuntu 14.04 at the base, but I like mint a heck of a lot better as a UI)

And it turns out some things are tweaky in regards filename conventions and so forth. Thus, this post. I'm using one of my Raspberry Pis as a source of images, and they are big - 3-4 MB each, and in timelapse mode, have strange filenames with lots of other numbers (time, date, ??, and timelapse sequence number in there somewhere). I'll have to go and mess with config files there to get something more reasonable. Glad I put 2 tb on this pi!

After a lot of looking, I found this link that gets it done (with mods):
http://techedemic.com/2014/09/18/creati ... th-avconv/
So this guy deserves some credit, as everyone else says just put in ffmpeg, which is kind of off the wall for a distro that is broken by it.
This is blazing fast as these things go, and uses all the cores of the cpu in parallel, and changed around 117 MB of stills (192 of them) into around 17 MB of video at 24 fps - and full resolution. 2592x1944 in this case - a little better than HD.

Here are the commands I wound up with (adapted from the link above).
Rename the files (They're all in a directory I made for this, and the terminal is cd'd to that directory already):
Code: Select all
ls *.jpg| awk 'BEGIN{ a=0 }{ printf "mv %s %04d.jpg\n", $0, a++ }' | bash


Since the ls sorts alphanumerically, they stay in order, and wind up with just the sequence number as a filename, with .jpg as the extension. This took about 1 second on a haswell NUC - mostly disk time I suspect. So now I have 192 files with reasonable names (a time lapse at 30 seconds per shot for a few hours today).

Then to make a movie:
Code: Select all
avconv -y -r 10 -i %4d.jpg -r 10 -vcodec libx264 -q:v 3  -vf scale=iw:ih tenfps.mp4;

for 10 fps or
Code: Select all
avconv -y -r 24 -i %4d.jpg -r 24 -vcodec libx264 -q:v 3  -vf scale=iw:ih twofourfps.mp4;

for 24 fps.

His example included cropping, which I didn't want and haven't tried, it looked like this:
avconv -y -r 10 -i %4d.JPG -r 10 -vcodec libx264 -q:v 3 -vf crop=4256:2832,scale=iw:ih tlfullhiqual.mp4;

(note, for the ones I used I changed .jpg to lower case, as that's what I get and like to use anyway - linux is case sensitive)

Normally, I'd have uploaded a vid to youtube - and let them take care of scaling, cropping and bitrates - their computers do it net faster than I can convert and upload the lower bitrate version anyway - and leave super high quality available for those who have the connection bitrate - but my test video so far could be described as "30 second timelapse shots of my yard while it got dark today" and no one really wants to see that. We're supposed to have some "exciting weather" tomorrow, and I plan to timelapse being buried in snow and ice and put that up when I have it - assuming it happens as predicted. That's why I was practicing how to do this today in the first place. I suspect at some point this is going to be pretty cool - maybe I should dedicate a pi to watching my garden grow and so on.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Time lapse movies from still jpegs

Postby Doug Coulter » Fri Jan 22, 2016 7:33 pm

Here's the video: https://youtu.be/pmHVY5e4VQ0


I'd feel cheated if I didn't have to try and move through this - hardly the epic (so far) snow we were warned of, though about 90% of what you see here - what fell all day after I started shooting - is tiny ice crystals that actually seemed to pack the snow down further, rather than build up height. Sigh, when you're testing, nature sometimes doesn't cooperate as you'd wish. But it worked! Didn't even take too long to do, though it maxed out a 4 core i5 haswell NUC for a few minutes to assemble the mp4.

Hint - the raspi software has an option to make a zip. This takes far more time than just copying via the normal file sharing I've set up here with samba on both ends, even at the pi's ~ 100 mbit rate. It took right around 5 min to copy 632 ~ 3 mb images. Zipping 192 the other night took 15 min and didn't reduce the size noticeably at all. Another few minutes on this machine to make the movie..haven't tried this all on the pi yet, but it would probably work. Took longer to upload than to do!

Here's an alternate solution, not yet tested by me:
sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
sudo apt-get install frei0r-plugins
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Time lapse movies from still jpegs

Postby Doug Coulter » Sat Jan 23, 2016 12:08 pm

I guess if you want to be awesome, you have to actually earn it and be awesome. Fail.
I should have left the porch light on last night...and kept going.
Icicles.jpg
Would have been cool to watch these grow...


I'll know better next time. Meanwhile, bonus picture. "The cats don't seem to care" sung to the tune of Steely Dan's FM would describe this one:
Bird.JPG
Maybe the cats are just waiting for these guys to get too fat to escape?

No fancy bird feeder required...
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Time lapse movies from still jpegs

Postby Doug Coulter » Sun Jan 24, 2016 8:47 pm

A little better one, since the sun was out. Nothing really special here, just having some fun when there's not much else to do, being snowed in and all.
https://youtu.be/faC9lxTbJ50
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Userland

Who is online

Users browsing this forum: No registered users and 2 guests

cron