{"id":13411477,"url":"https://github.com/google/mediapy","last_synced_at":"2025-05-15T21:03:41.147Z","repository":{"id":39372887,"uuid":"346856676","full_name":"google/mediapy","owner":"google","description":"This Python library makes it easy to display images and videos in a notebook.","archived":false,"fork":false,"pushed_at":"2025-05-01T10:18:29.000Z","size":1446,"stargazers_count":423,"open_issues_count":3,"forks_count":19,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-01T11:25:00.537Z","etag":null,"topics":["image","ironpython","jupyter-notebook","video","viewer"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/mediapy/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-11T22:27:57.000Z","updated_at":"2025-05-01T10:15:53.000Z","dependencies_parsed_at":"2023-11-13T18:29:21.895Z","dependency_job_id":"c5a55ad1-8d03-4e4e-afec-c837d7370233","html_url":"https://github.com/google/mediapy","commit_stats":{"total_commits":89,"total_committers":10,"mean_commits":8.9,"dds":0.5730337078651686,"last_synced_commit":"d8dead3c31e22038a40efd0d8faffb6775999627"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fmediapy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fmediapy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fmediapy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fmediapy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/mediapy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254422754,"owners_count":22068678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image","ironpython","jupyter-notebook","video","viewer"],"created_at":"2024-07-30T20:01:13.950Z","updated_at":"2025-05-15T21:03:41.119Z","avatar_url":"https://github.com/google.png","language":"Jupyter Notebook","readme":"# Read/write/show images and videos in an IPython/Jupyter notebook.\n\n[![Unittests](https://github.com/google/mediapy/actions/workflows/pytest_and_autopublish.yml/badge.svg)](https://github.com/google/mediapy/actions/workflows/pytest_and_autopublish.yml)\n[![PyPI version](https://badge.fury.io/py/mediapy.svg)](https://badge.fury.io/py/mediapy)\n\n[**[GitHub source]**](https://github.com/google/mediapy) \u0026nbsp;\n[**[API docs]**](https://google.github.io/mediapy/) \u0026nbsp;\n[**[Colab example]**](https://colab.research.google.com/github/google/mediapy/blob/main/mediapy_examples.ipynb)\n\n## Examples:\n\nSee the notebook \u0026nbsp;\n[`mediapy_examples.ipynb`](https://github.com/google/mediapy/blob/main/mediapy_examples.ipynb)\n\u0026nbsp; \u0026nbsp;\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google/mediapy/blob/main/mediapy_examples.ipynb)\n\u0026nbsp;\n[![Open in Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/google/mediapy/main?filepath=mediapy_examples.ipynb)\n\n\u003c!--\nDeepNote: The notebook runs correctly on https://deepnote.com/, but it cannot be\nlaunched from GitHub with a single click.  Instead, one must:\n- Start a notebook.\n- Create a Terminal (console).\n- Within the terminal, enter \"git clone https://github.com/google/mediapy.git\".\n- Navigate to Files -\u003e mediapy.\n- Open the *.ipynb notebook.\n\nKaggle: The notebook also runs correctly on https://www.kaggle.com/ although\n\"pip install -q mediapy\" requires first changing Settings -\u003e Internet -\u003e Enable,\nwhich in turn requires a phone number verification.  Also, the notebook cannot\nbe launched from GitHub with a single click but must be manually uploaded as a\nfile.\n--\u003e\n\n### Images:\n\n```python\n    !pip install -q mediapy\n    import mediapy as media\n    import numpy as np\n\n    image = media.read_image('https://github.com/hhoppe/data/raw/main/image.png')\n    print(image.shape, image.dtype)  # It is a numpy array.\n    media.show_image(image)\n\n    checkerboard = np.kron([[0, 1] * 16, [1, 0] * 16] * 16, np.ones((4, 4)))\n    media.show_image(checkerboard)\n\n    media.show_image(media.color_ramp((128, 128)), height=48, title='ramp')\n\n    images = {\n        'original': image,\n        'brightened': media.to_float01(image) * 1.5,\n    }\n    media.show_images(images)\n\n    media.write_image('/tmp/checkerboard.png', checkerboard)\n```\n\n### Videos:\n\n```python\n    url = 'https://github.com/hhoppe/data/raw/main/video.mp4'\n    video = media.read_video(url)\n    print(video.shape, video.dtype)  # It is a numpy array.\n    print(video.metadata.fps)  # The 'metadata' attribute includes framerate.\n    media.show_video(video)  # Play the video using the retrieved framerate.\n\n    media.show_images(video, height=80, columns=4)  # Show frames side-by-side.\n\n    video = media.moving_circle((128, 128), num_images=10)\n    media.show_video(video, fps=10)\n\n    media.write_video('/tmp/video.mp4', video, fps=60)\n\n    # Darken a video frame-by-frame:\n    filename_in = '/tmp/video.mp4'\n    filename_out = '/tmp/out.mp4'\n    with media.VideoReader(filename_in) as r:\n      print(f'shape={r.shape} fps={r.fps} bps={r.bps}')\n      darken_image = lambda image: media.to_float01(image) * 0.5\n      with media.VideoWriter(\n          filename_out, shape=r.shape, fps=r.fps, bps=r.bps) as w:\n        for image in r:\n          w.add_image(darken_image(image))\n    media.show_video(media.read_video(filename_out), fps=60)\n```\n\n## Setup:\n\nVideo I/O relies on the external program `ffmpeg`, which must be present in\nthe system PATH.  On Unix, it can be installed using:\n\n```shell\n    apt install ffmpeg\n```\n\nor within a notebook using:\n\n```python\n    !command -v ffmpeg \u003e/dev/null || (apt update \u0026\u0026 apt install -y ffmpeg)\n```\n","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fmediapy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fmediapy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fmediapy/lists"}