views:

84

answers:

3

I'm writing some physics simulations in c for university, and now I output a series of hundreds of png that I then watch in fast sequence... is there a way to merge them to a video in c with some simple lossless codec library?

P.S. I'm using cairo graphics and have very little experience in graphics programming in general

+1  A: 

Not exactly what you are asking for but I wouldn't roll my own, I would use mencoder:

mencoder mf://*.png -mf w=800:h=600:fps=25:type=png -ovc raw -oac copy -o output.avi

PS. mencoder is part of MPlayer and is Open Source. DS.

Jonas Elfström
nice suggestion.. maybe there's a way to pass input png through stdin and pipe them in without the need to save them all before...
luca
+2  A: 

If you want to avoid using an external program, libavcodec is probably the best way to generate video. It's in C, and quite well documented (see the above link).

More documentation on Jonas' solution using mencoder is here.

Chris Johnson
A: 

You just want to watch some PNGs as a video? You don't need to merge them:

mplayer -fps 2 mf://*.png

There are fast lossless codecs in ffmpeg's libavcodec, if you want to do that instead of write PNGs. e.g. ffvhuff, or huffyuv.

Or if you don't want to use libavcodec, you could write y4m raw output and pipe it to something. yuv4mpeg is a header with the frame rate and frame size, and then the uncompressed pixels for each frame just raw.

Peter Cordes