Limit video framerate of STATE_LOGGING_VIDEO_MP4

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Posts: 12
Joined: Fri Nov 03, 2017 8:21 pm

Limit video framerate of STATE_LOGGING_VIDEO_MP4

Post by MIT » Sat Jan 06, 2018 7:30 pm

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.

User avatar
Erwin Coumans
Site Admin
Posts: 4209
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Limit video framerate of STATE_LOGGING_VIDEO_MP4

Post by Erwin Coumans » Fri Jan 12, 2018 4:26 pm

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

while (1):
  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.

Posts: 12
Joined: Fri Nov 03, 2017 8:21 pm

Re: Limit video framerate of STATE_LOGGING_VIDEO_MP4

Post by MIT » Sun Jan 14, 2018 10:00 pm

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!

Post Reply