views:

1609

answers:

4

Well, simple situation. I've created about 5000 frames as PNG files which I want to display as an animation inside a .NET application. Every image is 1920x1080 in size and the PNG file uses alpha channels for (partial) transparency. And that's going to complicate things a bit, because I would prefer to keep it transparent. (But if that's impossible, I'll just add a background image to every PNG.)

Because of the large amount of images, I would need lots of memory. Well, a 1 TB harddisk and a 12 GB Quad-core Intel Xeon system running Vista 64-bits is solving those memory requirements. But unless a tool is created to support 64-bits, it will probably choke after loading perhaps 800 of the 5000 images. So I need a tool that can do this.

The movie format isn't that important. Neither is compression, as long as the image quality stays high. (And there's a reason why I've used such a huge resolution!) Lossless compression would be preferred, though. My system is fast enough to replay the movie afterwards again so I'm not worried about it's speed. However, image quality is the most important factor here.

So far, I've come up with two options: 1) I find some free tool which can handle this much data. (Free, or very cheap.) 2) I write such a tool myself...

Option 1 is a bit out-of-place here. Besides, as a software engineer, my hands are just twitching to write it myself! In C# with preferably no third-party libraries. So my question: - Where to start writing this myself?


(In case you're wondering, this movie is an animation where a young woman is walking through the streets of some city, passing several signs which mention features of a product. At the end of the movie, she walks up to a bigger sign which shows the name of the product itself. And it's one long, continuous scene, no breaks. And real fun to create too! And about 10 GB of images...)

+3  A: 

FFMPEG is capable of creating a movie file from a series of image files, this link to their manual shows an example:

http://ffmpeg.org/ffmpeg-doc.html#SEC5

As for creating the movie file programaticcaly with no third party libraries... that is going to be a bit more difficult. Many movie formats are tremendously complicated and to create one without an existing library would be pretty painful(unless I misinterpreted your question and you're not actually asking about creating the actual encoder)

If I didn't misinterpret your question, doing a simple implementation of a YUV based movie codec might be doable. HuffYUV is one I'm aware of that might not be too challenging.

Falaina
I'm not too fond of MPEG since it's a lossy compression format. I would like to have a lossless movie format first which I could then use to convert to any other format that I would like. There should be a lossless format somewhere, right? Doesn't matter if the final movie becomes 40 GB in size or whatever. I just need to have all 5000 images in one lossless movie format. Still, FFmpeg looks promising. Not sure if it can handle this much data, though. (Nor if it can be compiled to a 64-bits application.)
Workshop Alex
FFMPEG should have no problems ta all with handling that much data, if you do go down that route. For example I've used it to encode Elephant's Dream (http://www.elephantsdream.org/) before, which is available as about 12 GB of lossless pngs.
Falaina
Oh, I just noticed you wanting a preferably lossless movie codec. FFMPEG supports x264's (an h.264 encoder) lossless mode as well as a few YUV formats (like HuffYUV) which should also be lossless
Falaina
+4  A: 

Two things:

  • You're not going to write a proper video encoder by yourself. Not by a longshot. So your options are either to re-use an existing encoder, or not use an encoder at all.
  • No video format will deal with transparency. Either you give all the images a background, or you won't be able to use an existing video format.

There are a couple of solutions that spring to mind:

You don't care about size, but you do care about quality. First thing I would ask yourself is: do you really really not care about size? Most video formats (especially H.264) will give you excellent quality at a substantially lower file size (think 10x). You will barely be able to tell the difference. Yes, your content is HD, but HD content on TV or Blu-ray is also compressed (using H.264 or VC-1) and it's good enough for everyone else. So I would seriously consider this as an option, as it makes the rest a whole lot easier.

If you want, you can always resort to a lossless video format, such as HuffYUV. This will at least give you some compression, while cutting the size of your video data in half (or more).

As I said, by using an encoded video format, you lose the transparency. If you want to keep the transparency, and you still don't care about the file size, why not keep the PNGs and display them as a very fast slideshow in your application? If your only problem with this is the memory requirements of loading all PNGs into memory at once... don't do that. Read a couple of frames ahead (a fixed amount or as far as memory allows), and once you've displayed a frame, remove it from memory and read a new frame ahead. That way you get to keep perfect quality and constant memory requirements. The only issue is that your disk and processor will need to be able to keep up with the rate of reading 30 PNGs per second (or whatever your frame rate is).

Additionally, if 5000 separate image files get too unwieldy to handle, you can wrap them all in some custom file format. A ZIP file springs to mind as a simple portable format, or you can roll your own.

rix0rrr
Well, I want a master file which I can convert to other movie formats. So this master file needs to be the highest quality possible. So HuffYUV sounds good. But it needs to stay at 1920x1080 and HuffYUV doesn't seem to support this. About transparency, I already expected that this would not be possible, so no problem there. Size won't be a problem since the master file is stored on my system which has 1 TB disk space free.
Workshop Alex
+5  A: 

if you are on windows, you can also look into virtualdub. http://www.virtualdub.org/

it can make AVIs from bmps, pngs, etc.

clamp
Well, it's support 64-bits. :-) Downloading? Check! Install? Check! Running? Check! Convertion succeeded? YES! And with sourcecode available, so the perfect solution. :-)
Workshop Alex
I second this; this tool is excellent for making any set of images into a video. Install ffdshow and then you have access to H.264 encoder and others that will work at good quality for a high bitrate.
Callum Rogers
I couldn't use this program to read a folder of 5000 images and creating a video !!
arod
+1  A: 

You can do what you want with mencoder:

Here's a link from that documentation: Encoding from multiple input image files (JPEG, PNG, TGA, etc.)

About transparency: I don't think that there's a video codec that supports transparenct, so you're out of luck here...

Serafeim
Am very happy already with VirtualHub. :-) MEncoder looks good too, but the need for CygWin which doesn't make me happy. And finally, MEncoder does NOT support 64-bits Windows. VirtualHub does, so VirtualHub makes better use of my resources. Still, it looks like a good option.
Workshop Alex
Mencoder can be compiled for native windows with mingw, no cygwin is needed.You can find mplayer/mencoder windows binaries here http://oss.netfarm.it/mplayer-win32.php.
Serafeim