Export video in real time


#1

Hey! im actuallly using hamoid librarie video export. but frame rate still down. I need some way to record a sketch in real time( im moving cameras, and other events, so i need perfect sync). What alternatives do i have?what about if i make a system to keep track all variables? store all variables in a array and later “play” and then rec a video. what do you think? syphon to a external recorder?


#2

Hello. Can you please post the code you’re using to record your video?


#3

Hi @vjjv :slight_smile: What you suggest may work, but might not be as straightforward as it sounds.

If you want to produce a smooth video with 30 frames per second, you can play your system live while recording a time stamp and your camera positions and orientations. This will produce a file with data, but there will not be 30 timestamps per second. Very likely the time stamps will be irregularly spaced.

In phase two, when producing the video, you need to produce the frames to save. The rendering speed does not matter. Ideally you would interpolate the stored camera positions to figure out where the camera should be 30 times per second.

// saved camera position time-stamps
// A              B            C                  D            E
// *              *            *                  *            *               
// Needed camera positions at these regular time-stamps
// *         *         *         *         *         *         *   
// a         b         c         d         e         f         g

You need to know where the camera should be positioned at times
a b c d e f and g

a and g are easy, because they coincide with A and E, but all others probably should be interpolated.
For instance, at time b the camera should be between camera positions saved at times A and B. You interpolate position A towards position B, about 60% (because b is somewhat closer to B than A).
d is about 10% between C and D. e maybe 70% between C and D.

Another thing I could do is to implement what I suggested here:

One more option would be to use an external program to record the screen, like ffmpeg or something else. In Linux there’s simplescreenrecorder. In Mac you can use quicktime to record the screen. In Windows there’s a key shortcut to record the screen while you play video games.

The advantage of exporting frames one by one is that you can produce a smoother video without any dropped frames. The disadvantage is that it’s harder to do.


#4

Is a veryy large code… in resume, is a P3D sketch and a few PGraphics obj with shaders. The framerate normally is around 30/40 fps, when video rec is on, about 15.


#5

In that case I think you could try this: set the frame rate to 30 and make sure it runs at 30 fps stable. That means maybe deactivating shaders, reducing polygon count or whatever it takes. Then you could do the “saving data” phase, in which you record your interactions, camera positions, etc. This should produce 30 rows of data per second, saved maybe to a CSV file, json or something like that.

Then, as you suggested, you do the saving-video phase, in which you load the saved data and render each frame using the camera positions, interaction, etc as stored in the data file. This will probably run slowly, taking twice the expected time (because you said that when saving the video the program runs at 15 fps).

Once the program is done, you should have a video with the right number of frames and the right duration.

Do you think this is doable?


#6

give me a few days to study and implement some code. I need to think in a system, becouse in future i want to sync processing sketch via midi with ableton live, so when i save a video i need a perfect syncronisation with audio.