How to write video to disk in background
3 views (last 30 days)
Show older comments
Michael McConnell
on 17 Feb 2017
Commented: Michael McConnell
on 19 Feb 2017
I have a MATLAB GUI that includes a live preview from a camera. I am grabbing and displaying frames at ~24 fps. I would like to be able to record the incoming frames to a video file on the disk. I currently have a working implementation which uses VideoWriter to save each frame to an avi file. Unfortunately, when writing to disk, the GUI can become very unresponsive as the hard disk is quite slow. I would, therefore, like to save to disk in the background. I am using a 32bit Windows 7 pc where MATLAB has only ~2GB of RAM memory available but ample processing power. Is there an effective MATLAB function I could use to achieve this or a way to spawn a thread which can handle the disk save operation?
0 Comments
Accepted Answer
Walter Roberson
on 17 Feb 2017
The possibilities such as multithreading are likely to slow down processing because of the data transfer needs.
You should use the minimal processing to store the frames in order to do it most quickly. That means, for example, not using imwrite() because that has more processing. Instead you should consider just using fopen / fwrite / fclose to write the data as pure binary (you could also write a header file once that gave information about the number of rows and columns and color planes.) Afterwards you can go through and read the binary files and write them as image files if you need to.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!