Movie Maker video doesn't sync

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.

I’m working in Processing.py

1 Like

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:

  1. 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.

  2. 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.

  3. 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).

3 Likes

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.

I was exporting .jpg’s but .tga’s seem faster. Do we know for sure what exports quickest for lower drag?

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).

https://funprogramming.org/VideoExport-for-Processing/

2 Likes

Thanks again Cansik!

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

Did you try sketch > import library > add library? I see it listed there near the bottom of the list… if not, what OS and Processing version?

1 Like

Hi hamoid — I don’t see it nor does it appear with search “VideoExport” or “hamoid”.

I’m running processing 3 (3.5.3) on osx 10.10.5

What about “Video Export” with a space or “Abe”?

1 Like

Unfortunately no results.

You’re right. Somehow it is cached in my system but if you visit the library URL

http://download.processing.org/contribs

you can see the Video Export library very much gone. I don’t know why.

You can still find it at https://funprogramming.org/VideoExport-for-Processing/

2 Likes

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!

No problem :slight_smile:

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 :crossed_fingers:

1 Like

Awesome! It’s working locally. Looking forward to trying this out :slight_smile:

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 :slight_smile: 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.

1 Like

The withAudioViz example is exactly what I need. Now to translate to python!
Thanks to @cansik for the recommendation and @hamoid for the library.

1 Like

Thanks again @cansik — Turns out Syphon was perfect for this job.

1 Like