I'm a c programmer using code that calls routines like AVIStreamWrite(...) to output video to disk. It works just fine but is very slow.
On my computer (a surface pro 2) it takes between a third and two thirds of a second to compress and write a 1920 by 1080 32 bit frame, depending on the complexity of the image. That's using the Cinepack Codec by Radius, which is the only codec listed with AVISaveOptions(...) that gives good results, and that's at maximum quality, minimum compression.
At that rate, it's between ten and twenty seconds to output one second of video at 1080p, 30 fps. 10 minutes of video takes two or three hours to create.
So anyway the question is - is there any way to speed this up? For instance, can I add a faster modern codec, and if so how?
I'm sure my computer must have more modern codecs, but if so, AVISaveOptions doesn't seem to list them.
AVISaveOptions[
^]
And - some time, I'd like to add a native mp4 save to my program, or .mov, but don't know how to do it. Would those be faster to save to disk than the .avi?
And any good libraries or similar I can use for those compatible with C? I can also add C++ code to my program. I found a library to export mp4s by Google
Google Code Archive - Long-term storage for Google Code Project Hosting.[
^] but it didn't have any example code to show how to make an mp4, just how to make an empty mp4 which is not much use - and from looking at the source, it didn't seem to have any routines that take bitmap frames as arguments, so not sure if it can do what is needed.
I'm still using MSVC 6.0 which sometimes limits what I can do though usually I find a work arounds, e.g. by dynamically linking to newer dlls. And prefer to write in low level C (which is why I like MSVC 6.0 in preference to newer versions), but I can add C++ if there is good example code to follow.
Just to be clear - since the bottleneck is exporting the video to disk - I don't need code to convert my exported avi to mp4. I can do that with mencoder, or else I use other programs to convert avi to mp4.
Also - I'm not interested in code to convert exported single frames or exported uncompressed avi. They take about as long to export as the compressed avi.
I'm looking for a way to export directly to some compressed format such as mp4 or avi from my program.
Since avi is just a container format, you can use many different encoders inside of it. And I think some of the modern encoders you can use with avi might work well, but for some reason AVISaveOptions doesn't seem to list them.
It's also commercial software so whatever I use has to be under a suitable license to use with commercial software (shareware). The program is
[
^] and I use it for making videos of the program to upload to youtube, and sometimes users of the program need to make videos of the rhythms also.
Thanks!