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

江枫思渺然 提交于 2019-12-06 14:12:38

问题


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 1280x720, 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?


回答1:


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.



来源:https://stackoverflow.com/questions/1112941/rendering-a-sequence-of-images-in-c-sharp-to-make-a-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!