Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gym.wrappers.Monitor() produces empty video in 0.18.0 #2145

Closed
ish913 opened this issue Jan 5, 2021 · 5 comments
Closed

gym.wrappers.Monitor() produces empty video in 0.18.0 #2145

ish913 opened this issue Jan 5, 2021 · 5 comments

Comments

@ish913
Copy link

ish913 commented Jan 5, 2021

I can't play video produced by gym.wrappers.Monitor(). I solved this problem by downgrading gym to 0.17.3.

@daanklijn
Copy link

daanklijn commented Jan 6, 2021

Same issue when using only the VideoRecorder class.

Some code to reproduce the problem:

env = gym.make('Pong-v4')
env.reset()
recorder = VideoRecorder(env, path='/tmp/pong_video.mp4')

for i in range(1000):
    obs, _, _, _ = env.step(0)
    recorder.capture_frame()

recorder.close()

Output file is only 262 bytes, which seems quite a bit too small. I've also included the contents of the meta.json below.
image

{
  "content_type": "video/mp4",
  "encoder_version": {
    "backend": "ffmpeg",
    "version": "b'ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers\\nbuilt with Apple clang version 11.0.3 (clang-1103.0.32.62)\\nconfiguration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack\\nlibavutil      56. 51.100 / 56. 51.100\\nlibavcodec     58. 91.100 / 58. 91.100\\nlibavformat    58. 45.100 / 58. 45.100\\nlibavdevice    58. 10.100 / 58. 10.100\\nlibavfilter     7. 85.100 /  7. 85.100\\nlibavresample   4.  0.  0 /  4.  0.  0\\nlibswscale      5.  7.100 /  5.  7.100\\nlibswresample   3.  7.100 /  3.  7.100\\nlibpostproc    55.  7.100 / 55.  7.100\\n'",
    "cmdline": [
      "ffmpeg",
      "-nostats",
      "-loglevel",
      "error",
      "-y",
      "-f",
      "rawvideo",
      "-s:v",
      "160x210",
      "-pix_fmt",
      "rgb24",
      "-framerate",
      "30",
      "-i",
      "-",
      "-vf",
      "scale=trunc(iw/2)*2:trunc(ih/2)*2",
      "-vcodec",
      "libx264",
      "-pix_fmt",
      "yuv420p",
      "-r",
      "30",
      "/tmp/pong_video.mp4"
    ]
  }
}

@daanklijn
Copy link

I believe this is getting fixed in: #2139

@ish913
Copy link
Author

ish913 commented Jan 6, 2021

Oh, thank you!

@antoniopioricciardi
Copy link

In the meantime you can manually solve it by going to gym/wrappers/monitoring/video_recorder.py
and de-indent by une step the function call self.proc.stdin.write(frame.tobytes())
meaning that it does not have to be nested under any if statement.

@ish913
Copy link
Author

ish913 commented Feb 12, 2021

Thank you for noticing!

RajK853 pushed a commit to RajK853/RL_OpenAI_Gym that referenced this issue Aug 31, 2021
- Downgrade gym to ``0.17.0` because of the recording issue mentioned [here](openai/gym#2145)
- Fix package for tensorflow-gpu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants