fix(notebooks): play() emits even (h,w) so video plays in JupyterLab#29
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The rendered-movie cells in the teaching notebooks (
01_anatomy.ipynb'splay(_frames4, …)cell and the same helper in02_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 onlyheighttomediapy.show_videoand let mediapy derive the width, which could land on an odd value. Odd dimensions cannot encode asyuv420p, 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):yuv420p-encodableThe source is also padded to even dimensions first, covering the case where mediapy declines to upscale a tiny clip.
Testing
(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.play(...)cells now render and play inline.Fixes #28
🤖 Generated with Claude Code
📚 Documentation preview 📚: https://minisim--29.org.readthedocs.build/en/29/