Search code examples
reinforcement-learningopenai-gymstable-baselines

Can't set the frame rate when recording a video with VecVideoRecorder


I have a working RL model and set up that produce a video for me - however becuase the model is reasonably good, the videos are very short (reach a desitination therfore better = shorter)

Is there a way to drop the frame rate of the video output? I know it can be done with a gif. And that it can be done with ffmpeg but I can't workout how to pass it down.

I've dropped the fps in my environment from 50>10 expecting the video to be 5 times as long but that didn't work.

Save me stackoverflow you're my only hope. (appart from posting on github)


Solution

  • When you say that you dropped the fps from 50 to 10, I assume you changed env.metadata.video.frames_per_second, which initializes to 50 (for gym versions less than 0.22.0):

    {
      'render.modes': ['human', 'rgb_array'],
      'video.frames_per_second': 50
    }
    

    Starting with gym 0.22.0, VideoRecorder class gets the frames_per_sec to write the video with:

    env.metadata.get("render_fps", 30)
    

    Setting env.metadata["render_fps"] = 4 should result in a slowed down video.