I have some time series data that I would like to create into movies. The data could be 2D (about 500x10000) or 3D (500x500x10000). For 2D data, the movie frames are simply line plot using plot
, and for 3D data, we can use surf
, imagesc
, contour
etc. Then we create a video file using these frames in MATLAB, then compress the video file using ffmpeg
.
To do it fast, one would try not to render all the images to display, nor save the data to disk then read it back again during the process. Usually, one would use getframe
or VideoWriter
to create movie in MATLAB, but they seem to easily get tricky if one tries not to display the figures to screen. Some even suggest plotting in hidden figures, then saving them as images to disk as .png
files, then compress them using ffmpeg
(e.g. with x265
encoder into .mp4
). However, saving the output of imagesc
in my iMac took 3.5s the first time, then 0.5s after. I also find it not fast enough to save so many files to disk only to ask ffmpeg
to read them again. One could hardcopy
the data as this suggests, but I am not sure whether it works regardless of the plotting method (e.g. plot
, surf
etc.), and how one would transfer data over to ffmpeg
with minimal disk access.
This is similiar to this, but immovie
is too slow. This post 3 is similar, but advocates writing images to disk then reading them (slow IO).