Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Make a video using several .png images [closed]

Tags:

python

I'm trying to make a video using a series of .png images. I found this Python script, but I am not entirely sure on how to use it:

https://sites.google.com/site/timelapsepy/home

I also tried to look into opencv, but it doesn't seem to install properly for me. Any ideas on a simple program to string several images together to create a time-lapse video? I would like to use Python for this if possible.

like image 550
user1620716 Avatar asked Nov 27 '12 18:11

user1620716


People also ask

Does Python support PNG?

INSTALLATION. PyPNG is pure Python and has no dependencies. It requires Python 3.5 or any compatible higher version. to access the png module in your Python program.


2 Answers

If you really need a scripted python solution, you can look into using PIL

But if you just want to easily convert a sequence of png images to a movie, you can simply use ffmpeg:

ffmpeg -f image2 -r 1/5 -i image%05d.png -vcodec mpeg4 -y movie.mp4

This command takes images with 5 digit padding (image00001.png) and compresses them into an mpeg4 quicktime, at a rate of holding each frame for 5 seconds. You could do a different fps if your images are greater: -r 24 (24 frames per second)

like image 133
jdi Avatar answered Oct 19 '22 19:10

jdi


Instead of ffmpeg, you might want to use avconv

avconv -f image2 -i figMatplotlib%d.png -r 76 -s 800x600 foo.avi
like image 28
Qin Chen Avatar answered Oct 19 '22 18:10

Qin Chen