We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I recently created an audio visualizer with the Minim library. I would now like to render it into mp4. I have tried using saveFrame() to create images of the animation but when I later combine the images into an mp4 file the video does not sync with the audio anymore. I am assuming this is because the saveFrame() function is expensive and can not create the correct amount of images in the time given by the program running. So my question now is how can I render my Processing animation such that when I render it into mp4 the animation matches with audio when I combine the video and audio together in a editing software.
Answers
Not only saving operations are expensive, but also loading are also almost as much! :-&
If you got RAM to spare, you may replace saveFrame() w/ get() and add() them all to an ArrayList of PImage:
Once the animation is finished, traverse that whole ArrayList<PImage>, use get(), then invoke save():
https://Processing.org/reference/PImage_save_.html
Hopefully all of those stored PImage were able to be taken @ ~60 FPS.
And be still synched to the Minim sound played. :-\"
I saw your previous post when you stated this, but Im confused when I evoke the get() call as right now in my code when I run it I get a OutOfMemoryError cause the array is getting too big?
` import ddf.minim.*; import ddf.minim.analysis.*;
I added this condition within the draw function, but all it saves is the last frame image 600 times
I've already warned about it would only work if you had enough RAM to spare!
There are 2 get() methods:
Processing's API version you've got it right:
shots.add(get());
For List, you've got it at the wrong place:
for(int i=0; i!=shots.size(); shots.get(i++)) {}
Besides, you've called the wrong save():
save(frame + nf(i,4) + ".tif");
https://Processing.org/reference/save_.html
I don't even know where that frame variable above comes from! @-)
Rather you were supposed to call PImage's own save() method:
https://Processing.org/reference/PImage_save_.html
Made a new saveShots() version example which relies on an enhanced
for ( : )
loop rather than the regularfor ( ; ; )
: https://Processing.org/reference/for.htmlThis version doesn't need List's get() method. It's done behind-the-scenes: :-bd
For comparison, here's the same saveShots(), but relying on a regular
for ( ; ; )
and List's get() method: >-)