Is there a RAM efficient way to export a video?

5 views (last 30 days)
I have code that analyzes a video makes some markings on the video and then saves an output video.
I've saved the output video as frames using export graphics and then go back through those and save the video afterward.
The process of exporting the frames causes the RAM use to increase beyond what the computer has (32GB). This is true even when the video output video is much smaller in size than this.
Is there a way to export a video or frames that won't cause the ram use to increase indefinately?
(I've tried to clear variables related to the frames but that didn't seem to work. Maybe I didn't do it correctly)

Answers (1)

Walter Roberson
Walter Roberson on 28 Apr 2022
If possible, instead of displaying the frames and drawing on them and using export graphics, try using Computer Vision Toolbox insertShape() and insertText() to draw onto an in-memory array, which you can then imwrite() to a file.
  3 Comments
Walter Roberson
Walter Roberson on 30 Apr 2022
You cannot imwrite() a displayed figure -- but you can imwrite() the data that you would have displayed in the figure (but that might involve using insertShape() or insertText() to draw on top of the data array.)
Ian Bentley
Ian Bentley on 1 May 2022
Edited: Ian Bentley on 1 May 2022
You can convert an axes to an image and then export that with imwrite. That approach worked nicely.
Thank you again for the help!

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!