Skip to content

fix(notebooks): play() emits even (h,w) so video plays in JupyterLab#29

Merged
daharoni merged 1 commit into
mainfrom
fix/play-even-dims-jupyterlab
Jun 23, 2026
Merged

fix(notebooks): play() emits even (h,w) so video plays in JupyterLab#29
daharoni merged 1 commit into
mainfrom
fix/play-even-dims-jupyterlab

Conversation

@daharoni

@daharoni daharoni commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

The rendered-movie cells in the teaching notebooks (01_anatomy.ipynb's play(_frames4, …) cell and the same helper in 02_demixing.ipynb) showed a blank video box reading "No video with supported format and MIME type found" when run in JupyterLab in a browser.

play() passed only height to mediapy.show_video and let mediapy derive the width, which could land on an odd value. Odd dimensions cannot encode as yuv420p, so browsers refuse to play the clip. It went unnoticed because the notebooks were authored/run in VS Code, where playback is more permissive.

Fix

play() now computes an explicit even (height, width):

  • height capped to the source (never upscale)
  • width aspect-matched
  • both rounded down to even → always yuv420p-encodable

The source is also padded to even dimensions first, covering the case where mediapy declines to upscale a tiny clip.

Testing

  • Verified end-to-end in the project venv: odd (101, 99), odd-square (99, 99), even (100, 100), and large (600, 800) clips all resolve to even output dimensions and encode to valid HTML5 video.
  • Confirmed in JupyterLab in a browser: the play(...) cells now render and play inline.

Fixes #28

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://minisim--29.org.readthedocs.build/en/29/

play() passed only height to mediapy.show_video and let it derive the
width, which could land odd. Odd dimensions cannot encode as yuv420p, so
browser-based JupyterLab refused to play the clip ("No video with
supported format and MIME type found"); VS Code tolerated it, so it went
unnoticed.

Compute an explicit even (height, width): cap height to the source (never
upscale), aspect-match the width, round both down to even. Pad the source
to even dims first, covering the case where mediapy declines to upscale a
tiny clip. Output now encodes as yuv420p and plays in all browsers.

Fixes #28

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@daharoni daharoni merged commit 71341a4 into main Jun 23, 2026
11 of 12 checks passed
@daharoni daharoni deleted the fix/play-even-dims-jupyterlab branch June 23, 2026 16:46
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.

play() renders unplayable video in JupyterLab — "No video with supported format and MIME type found"

1 participant