Simulation Time Linked Video Recorder

Requests or suggestions for new features
Wilsonator
Posts: 45
Joined: 25 Sep 2015, 19:10

Simulation Time Linked Video Recorder

Postby Wilsonator » 01 Aug 2016, 19:40

I would like to have a video recorded that attempts to capture video at regular simulation time intervals, instead of based solely on frame rate.

This would allow for play back in "real time" for simulations that are run much slower (or quicker) than real time, and also for play back at explicit speeds such as 1/4 speed.

I understand that this may be a challenge since the video recorder only captures frames at the speed the GPU is rendering the scene, so I have a suggestion.

Possible you could have an option to "capture frame every x.xxx seconds of simulation time" and keep the frame rate parameter available so we can define the playback speed of the final video. Now to address the technical challenge, get V-Rep to capture the next frame the GPU renders after x.xxx seconds of simulation time elapses. This should produce an effect as close as possible to capturing a frame every exact x.xxx second.

Now it is possible that based on user setting for this if x.xxx is set too small for the speed the simulation is running (e.g. large time step leading to quick simulation), that this strategy will fail completely, which might be why you haven't implemented such a thing to begin with! I suggest just implementing a warning message into the console if during run-time the video capture cannot keep up (within some defined error threshold margin), or maybe into the info header or something?

Thanks!

coppelia
Site Admin
Posts: 5728
Joined: 14 Dec 2012, 00:25

Re: Simulation Time Linked Video Recorder

Postby coppelia » 02 Aug 2016, 13:02

Hello,

If I understand you correctly: you want to be able to record a frame on a regular time basis (in simulation time).
This is actually how the recorder is working right now: imagine you have a very slow simulation, that advances at 1s (simulation time) for 10 seconds real-time. If you want to generate a video that plays-back the recorded frames in 1 second real-time, then:

  • By default there will be 20 frames for one simulation second (i.e. the simulation time step is 50ms)
  • This means that the recorder will capture exactly 20 frames during 1 second simulation time
  • By default, each displayed frame will be recorded.
  • By default, a video with 20 frames/second will be generated
  • This means that by default, your video will play-back the recorded frames in exactly 1 second.

Now, above are the default settings that you can somehow modulate:

  • if you decide to skip every other frame (i.e. if you specify 2 for item displayed frames result in 1 recorded frame), then your video will play-back twice as fast. This item allows to skip 0 frames, 1/2, 3/4, 7/8, etc., basically always dividing the number of frames in the resulting video. We cannot have a gradual adjustment (e.g. skip 1/4 frames), because the video would otherwise appear speeding up / slowing down constantly, since the time-step between individual frames would not be constant anymore.
  • if you want to keep all the frames but simply play-back the video twice as fast, then you can set the frame rate to 40 (instead of 20 frames for one second)
  • if you want to play-back the video twice as slow, then you can set the frame rate to 10 (instead of 20 frames for one second)
  • etc.

Cheers

Wilsonator
Posts: 45
Joined: 25 Sep 2015, 19:10

Re: Simulation Time Linked Video Recorder

Postby Wilsonator » 04 Aug 2016, 00:16

Ok I think I understand. Let me give my example.

Simulation running with a dt=0.20ms

This is 5000 steps per second.

I set 'displayed frames result in 1 recorded frame' to 125 (5000/125 = 40). Therefore 40 frames should be recorded for every 1 second of simulation time.

I then could set 'frame rate' to 40f/s for a 1x speed video. Or as another example I could set 'frame rate' to 20f/s for a 0.5x speed video.

Is this correct?

If this is correct, I think 'displayed frames result in 1 recorded frame' is misleading (unless there is a reason to say it this way?).

It would seem to me that saying something like 'x simulation time steps result in 1 recorded frame' would be more accurate? Saying 'displayed frames result in 1 recorded frame' makes me think that this value is affected by how fast my GPU is rendering and displaying frames in V-REP.

Wilsonator
Posts: 45
Joined: 25 Sep 2015, 19:10

Re: Simulation Time Linked Video Recorder

Postby Wilsonator » 04 Aug 2016, 00:53

I just ran a test on my simulation. Setup was:

Time step dt =0.2ms
125 displayed frames result in 1 recorded frame
frame rate = 40f/s

Resulting video file after ~1.7s simulation time (about an hour real-time):
205 frames
40fps
total length 5.125s

From this I see that I am not getting the 1x speed video that I was attempting to record. I am still confused on how this is working!

coppelia
Site Admin
Posts: 5728
Joined: 14 Dec 2012, 00:25

Re: Simulation Time Linked Video Recorder

Postby coppelia » 04 Aug 2016, 13:36

I obtain exactly what is expected. I have:

  • simulation time step of 0.0002 (set in this dialog)
  • in this dialog, I have:
    • Launch at next simulation start checked
    • 125 displayed frames result in 1 recorded frame
    • Automatic frame rate unchecked
    • Frame rate [f/s] 40

Then I start the simulation. It is convenient also to have a non-threaded child script (for instance) that stops the simulation once the desired simulation time has been reached (with simStopSimulation). Depending on the scene content, the simulation will run a few more frames before stopping after you issued that command.

What might be happening in your case:

  • it could be that some of the video encoders do not support a frame rate different than 20 f/s.
  • it could be that you have the threaded rendering enabled. That brings a random component into the displayed frame counting, since frames will not be displayed on a regular basis anymore.

I understand that the displayed frames result in 1 recorded frame-item might sound confusing. However it is really like that: by default, one frame is sent to the screen for each simulation step (i.e. when not using threaded rendering). Additionally, you can skip frames by clicking the rabbit toolbar button (if you click it once, then only every other frame will be displayed on the screen. If you click it twice, then only every 4th frame will be displayed, etc.) From those displayed frames, you can skip even more with the displayed frames result in 1 recorded frame-item.

Cheers


Return to “Feature requests”

Who is online

Users browsing this forum: No registered users and 6 guests