Page 1 of 1

Limit video framerate of STATE_LOGGING_VIDEO_MP4

Posted: Sat Jan 06, 2018 7:30 pm
by MIT
As the title states, is there a way to constrain the framerate of the video created using the command:

p.startStateLogging( p.STATE_LOGGING_VIDEO_MP4, filename )

As of now, the framerate fluctuates based on the cpu load of my computer. If this is connected to the framerate that the Physics simulator is running at perhaps I'm not setting it correctly? I'm currently using:

p.setPhysicsEngineParameter( fixedTimeStep=1./60., ... )

But reducing the fixedTimeStep value seems to have no effect on the logging. I've also tried the following on playback and it fails to solve the issue.

p.setRealTimeSimulation( True )

I'm probably mis-understanding how bullet works, but any help would be appreciated.

Re: Limit video framerate of STATE_LOGGING_VIDEO_MP4

Posted: Fri Jan 12, 2018 4:26 pm
by Erwin Coumans
At the moment, the ffmpeg video stream is generated from the graphics thread, which runs asynchronously from the physics. It cannot be synchronized.

We can add an option to force to synchronize them for this purpose, you could file an issue in our tracker?

Alternatively, just grab the individual images using 'getCameraImage' and create the video from Python?

Code: Select all

p.setRealTimeSimulation(False)
while (1):
  p.stepSimulation()
  img=p.getCameraImage(width, height, renderer=p.ER_BULLET_HARDWARE_OPENGL)
  #save image to disk or stream img to a ffmpeg pipe
See the PyBullet Quickstart Guide for details on getCameraImage.

Re: Limit video framerate of STATE_LOGGING_VIDEO_MP4

Posted: Sun Jan 14, 2018 10:00 pm
by MIT
Thanks for following up, that explains the behavior I'm seeing. I'll file an issue with the tracker as I think it's a worthwhile option.

That said, just grabbing the images and compositing them into a video later is a good solution, so I'll use that as a workaround in the meantime. Didn't realize this method existed, should have looked harder at the API. Interestingly this is actually the preferred way to render video in Blender, save images to disk and then create the video as a second step. That way if your render takes 3 days and fails half way thru you don't have to restart the thing from scratch. Thanks for the help!