I’ve got an issue with the native Movie Maker where the video rate exports with a framerate greater than specified. My sketch reacts to sound input so it’s clear to see that the exported .mov visuals don’t sync with the sound.
Both frameRate(30) is defined in setup() and a framerate of 30 set in the Movie Maker options.
Just because you set frameRate(30) does not guarantee you a constant framerate of 30 FPS. Usually it’s about 28 to 29 FPS. Saving frames to a file costs a lot of computing power and so your sketch will run at about 10-15 FPS.
Now there are multiple solutions for this problem:
You could store the frames in a PGraphics list and buffer them till the recording ended, then save all the frames. This is possible, but it depends on the time you would like to record, because you don’t have unlimited memory. You could counter that with a separate thread, which then writes the PGraphics async onto the disk. But this maybe is slow too, because you would have to store the pixels on the CPU (with loadpixels) and GPU - CPU transfers can not be done multithreaded.
You write your software as a frame by frame renderer instead of a live renderer. You first define how long the animation should take, and then interpolate frame by frame for the animation. This of course can not react to live music, but it would be possible to read the audio file sample by sample.
Maybe the best solution is to use another software for recording. Send your sketch through syphon to a software which is capable of recording syphon streams (f.e. syphon recorder).
Ah… I had suspected as much. Thank you for the detailed response and suggestions.
I had thought that perhaps had a frame not corresponding to time been saved then the moviemaker would recycle a previous one as a placeholder. But of course it can’t because they’re named iteratively versus some framerate structure.
Check out the following library which is for direct video export (ffmpeg). It seems to be a bit faster then directly writing to the disk (opinion based, not measured).
Is it possible to use this library in python mode? I installed ffmpeg no problem but there doesn’t seem any way to install VideoExport via sketch > import library. cc @hamoid
Sorry to ask such a noob question but how do I install it outside of the UI? I tried putting ‘com’ in a libraries folder (which is in the sketch folder) but even in java mode I get “The import com.hamoid cannot be resolved”. I really would like to continue working in python!
com? maybe you downloaded the source code instead?
At the top of the page click download, which scrolls to the middle of the page, where you can download a zip file. The file contains a VideoExport folder, which you drop into your Processing libraries folder. Then restart Processing and
Awesome! It’s working locally. Looking forward to trying this out
Your reply sort of sounds like there’s a more general folder for adding processing libraries as opposed to storing local to the sketch folder. Is that true?
That’s true Your sketchbook folder (which you can find in the Processing Preferences screen) should contain a libraries folder. That’s where you put libraries that can be used by all your sketches.