I'm creating a code that outputs arrays that change over time per iteration. The details don't matter too much; I just need a way to get the arrays that are outputted, save them, and then stitch them into an mp4.
Here's the basic idea:
def display(A):
%matplotlib qt
plt.rcParams['figure.figsize'] = [6, 6/maxX*splitmarker] #maxX and splitmarker are the dimensions of the array
plt.imshow(A, interpolation = 'nearest', cmap = 'Blues');
plt.axis('off');
plt.show()
plt.draw()
plt.pause(0.2)
to actually display the array A. Then, for a previously defined number of iterations,
for i in iterations:
#the array is changed
display(A)
This displays a new array A for every i. I'm trying to find a way to get all of those displays and stitch them together in a single mp4 file (so you can see how A progresses in time). There are 2 main obstacles I'm running into:
1: I don't know how to save the arrays as individual PNGs.
2: Even if I did know how to do that, I don't know how to convert the PNGs into an mp4 using Python.
I've already tried using FFMpegWriter and OpenCV3, but I can't figure out how to actually implement them into my code. Ideally, I'd like to do something like this example FFMpegWriter function, but it doesn't really work (since I can't define a DPI that works for the array).
Thanks in advance!