0

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)

TimNewman
  • 13
  • 4

1 Answers1

0

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.

tacon
  • 321
  • 1
  • 6
  • Thanks I had set render_fps in the environment already. I tried both: env.metadata['video.frames_per_second']=4 env.metadata["render_fps"] = 4 And neither of them made a difference. Could this be an anaconda implementation thing - its still gym=0.21 I think – TimNewman Feb 06 '23 at 09:33
  • Looks like the current, or last week anyway 2023/02/01, anaconda SB uses gym=0.21. so it was 'video.frames_per_second':4 It only worked if I put it in the environment though - setting it like env.metadata["video.frames_per_second"] = 4 didn't work. – TimNewman Feb 06 '23 at 10:15
  • I've marked it as the answer but I guess updating it to say which versions they apply to would be helpful for future reference. Thanks! – TimNewman Feb 06 '23 at 10:15
  • I just added the versions, the syntax `env.metadata["video.frames_per_second"] = 4` is the only one I could get to work. I guess you defined a custom environment and declared the metadata as a JSON. – tacon Feb 06 '23 at 14:27