Saving direct to video file
AnsweredHi,
I am trying to get familiar with developing with the spinnaker c++ SDK. I'm currently managing decently, and have a script doing my video recordings from a couple of FLIR blackfly cameras, but am struggling with the best way to save the recordings to my computer. Currently at high frame rates, the only way I can get it to work is by saving individual BMP images to my hard drive, since compressing to JPEG seems to add too much overhead and I get issues. However I am also familiar with the SpinView software, where I am able to set up recordings to save directly into an AVI as the recording goes, which seems to work well, but I can't seem to figure out how to do this in the SDK as I don't think there's an example that does this. I'm doing long recordings so the example given on recording to memory and then saving after wouldn't work. Any help or advice you can give would be really helpful.
Thanks,
Stefan
-
Official comment
Thanks Gregory and Manuel for your ideas and feedback.
Using OpenCV and looking at our AcquisitionMultipleCamerasWriteToFile example are good ways to get over the issue of the conversion time being longer than the incoming framerate.
We also have an example of taking saved raw images and loading them back into Spinnaker objects to save your AVI in post processing (Spinnaker-Examples/RawToProcessed at main · Teledyne-MV/Spinnaker-Examples · GitHub). Saving images as raw would be the quickest method to save, however it would take a lot of hard drive space.
SpinView does save AVIs as well as you mention, but it buffers images in RAM if the write speed is slower than the incoming datarate. To do this in the API, you would allocate as many buffers as you can for the RAM that you have, use the OldestFirst buffer handling method, and grab/save your images to avi. This way you have a slower increase in your used RAM depending on your processing/write speed, and you don't have to buffer up your whole recording before saving your AVI.
Our BufferHandling example code in our SDK can help with setting the correct mode and the number of buffers.
Thank you,
Demos
-
Hello,
An example of how to create an AVI file is provided with the SDK : Project name is SaveToAvi
Best regards,
0 -
Hi,
Thanks for the reply. I've seen that example but as far as I can tell doesn't script just save the video into memory first and then compress after? I'm looking to do some very long recordings and wouldn't have the RAM for that if so, so am looking to see if there's a way that writes to a video file on the fly. Do you know if the example given is the same way that SpinView processes video saving under the hood? Let me know if I'm mistaken though.
Thanks,
Stefan
0 -
Hello,
I am not an expert in Flir SDK. I don't know if this is possible with the SDK. Perhaps you should take a look at the Opencv library ?
From memory, you can create videos on the fly ...
Best regards,
0 -
Ok, I'll look further into it. Thanks for the help.
Stefan
0 -
Hi Stefan, if processing and saving takes too long, you might also want to take a look at the source code example AcquisitionMultipleCamerasWriteToFile. That example saves the raw image data to a big single file first and extracts images for processing after recording finishes.
Manuel0 -
Hi all,
Thanks very much for the help, I'll try implementing some of these suggestions and see what works best. Glad you mentioned the way the WriteToFile example works, I'd missed that detail, seems like a good solution.
Thanks again,
Stefan
0
Please sign in to leave a comment.
Comments
7 comments