Skip to content

Conversation

@virgilt
Copy link
Contributor

@virgilt virgilt commented Nov 25, 2025

Description

This PR fixes the broken --capture-video option in the CleanRL Advanced PPO tutorial (tutorials/CleanRL/cleanrl_advanced.py). The original implementation attempted to use Gymnasium’s RecordVideo wrapper, which does not support PettingZoo’s parallel environments or SuperSuit’s vectorized wrappers. As a result, enabling --capture-video always produced an exception or silently failed.

This PR replaces the unsupported wrapper with a post-training video recorder that:

  • Creates a fresh, non-vectorized Atari environment with render_mode="rgb_array"
  • Replays the trained policy for a configurable number of frames
  • Captures RGB frames and writes an MP4 using imageio
  • Saves the video inside the same TensorBoard run directory for easy experiment tracking

This restores full video-recording functionality for the tutorial and provides a more reliable, backend-agnostic way to generate videos of trained PettingZoo agents.

Additional changes

  • Added imageio and imageio-ffmpeg to the tutorial requirements.txt since MP4 writing requires them.
  • Added a small message clarifying why RecordVideo is disabled for vectorized multi-agent environments.

Fixes # (issue), Depends on # (pull request)
N/A

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Screenshots

N/A

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have run pytest -v and no errors are present.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I solved any possible warnings that pytest -v has generated that are related to my code to the best of my knowledge.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@virgilt virgilt merged commit 9c1c5f1 into master Nov 25, 2025
32 of 45 checks passed
@virgilt virgilt deleted the fix/cleanrl-video-recording branch November 25, 2025 04:21
@virgilt virgilt restored the fix/cleanrl-video-recording branch November 25, 2025 04:25
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

Successfully merging this pull request may close these issues.

2 participants