C# – Rendering a Sequence of Images in C# to make a video

ccompressionjpegvideo

I have a sequence of jpg images that I am capturing and rendering to the screen to create a video.

I am decompressing the image from a MemoryStream using a JpegBitmapDecoder and rendering it by setting the Source on an Image control. This seems to work okay, but the processor overhead is pretty high. The images are 1280×720, running at 30fps and I can just barely keep up on my computer ( Dual Core 2.8Ghz). Running at higher resolutions cause me to throw away frames. I would like to try to get the cpu utilization down.

Most of the time spent spent seems to be in the decoding (simple benchmarks of the decoding alone on my machine put show that I can decode about 40fps). Does anyone know if there is a faster decoder available (DirectX? DirectShow? Something I can offload to the video card?)

As for the rendering, it doesn't seem like the Image control is designed for this type of use (I was actually surprised it worked at all, i just tried it because it was easy to do). Is there another way to render the individual frames that might be faster?

Best Answer

It sounds like you are both decoding and resizing the jpeg at the same time. The resizing can be expensive too. Try separating decoding and resizing (using the cheapest algorithm available) the jpegs. Use something like FreeImage with "JPEG_FAST" to decompress and "FILTER_BOX" to resize.

For display, TinyPTC is simple and fast. (a wrapper around DirectDraw) It is C, but it is pretty easy to write a wrapper for and compile to a dll you can reference.

Related Topic