{"id":19191433,"url":"https://github.com/rezoo/movis","last_synced_at":"2025-04-05T00:06:32.609Z","repository":{"id":212277416,"uuid":"678676229","full_name":"rezoo/movis","owner":"rezoo","description":"Python library for video editing, presentation video generation, motion graphics, shader art coding, and other video production tasks","archived":false,"fork":false,"pushed_at":"2024-05-25T14:57:04.000Z","size":19894,"stargazers_count":322,"open_issues_count":9,"forks_count":17,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-13T11:59:10.010Z","etag":null,"topics":["animation","animation-engine","motion-graphics","python","video","video-editing","video-processing"],"latest_commit_sha":null,"homepage":"https://rezoo.github.io/movis/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rezoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2023-08-15T05:15:04.000Z","updated_at":"2024-07-12T18:47:22.000Z","dependencies_parsed_at":"2023-12-20T07:34:15.221Z","dependency_job_id":"ed0b9879-391e-4161-9554-8f932bd48e00","html_url":"https://github.com/rezoo/movis","commit_stats":null,"previous_names":["rezoo/movis"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezoo%2Fmovis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezoo%2Fmovis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezoo%2Fmovis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezoo%2Fmovis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rezoo","download_url":"https://codeload.github.com/rezoo/movis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266563,"owners_count":20910836,"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":["animation","animation-engine","motion-graphics","python","video","video-editing","video-processing"],"created_at":"2024-11-09T11:43:06.895Z","updated_at":"2025-04-05T00:06:32.590Z","avatar_url":"https://github.com/rezoo.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"![GitHub Logo](images/movis_logo.png)\n\n# Movis: Video Editing as a Code\n\n[![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue)](https://www.python.org)\n[![pypi](https://img.shields.io/pypi/v/movis.svg)](https://pypi.python.org/pypi/movis)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/rezoo/movis)\n![Continuous integration](https://github.com/rezoo/movis/actions/workflows/python-package.yml/badge.svg)\n![Docs](https://github.com/rezoo/movis/actions/workflows/docs.yml/badge.svg)\n\n[**Docs**](https://rezoo.github.io/movis/)\n| [**Overview**](https://rezoo.github.io/movis/overview.html)\n| [**Install Guide**](https://rezoo.github.io/movis/install.html)\n| [**Examples**](https://github.com/rezoo/movis/tree/main/examples)\n| [**API Reference**](https://rezoo.github.io/movis/reference/index.html)\n| [**Contribution Guide**](https://rezoo.github.io/movis/contribution.html)\n\n## ✅ What is Movis?\n\nMovis is an engine written in Python, purposed for video production tasks.\nThis library allows users to generate various types of videos,\nincluding but not limited to presentation videos, motion graphics,\nshader art coding, and game commentary videos, through Python.\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/rezoo/movis/blob/main/docs/Quickstart.ipynb)\n\n## 🚀 Main Features\n\n* Easy and intuitive video editing (including scene cut, transition, crop, concatenation, inserting images and texts, etc.)\n* Inserting text layers containing multiple outlines\n* Simple audio editing (including fade-in and fade-out effects)\n* Support for a variety of video and audio formats using ffmpeg\n\nThe following features are not found in other Python libraries for video editing:\n\n* Layer transformation (position, scale, and rotation) with sub-pixel precision\n* Support for a variety of Photoshop-level blending modes\n* Keypoint and easing-based animation engine\n* Nested compositions\n* Support for rendering at 1/2 quality and 1/4 quality for drafts\n* Fast rendering using cache mechanism\n* Adding user-defined layers, effects, and animations without using inheritance\n* Layer effects (drop shadow, grow, blur, chromakey, etc.)\n\nTo put it simply, Movis is a library for complex video editing that includes several features found in proprietary software.\n\n## 💻 Installation\n\nMovis is a pure Python library and can be installed via the [Python Package Index](https://pypi.org/):\n\n```bash\n$ pip install movis\n```\n\nWe have confirmed that it works with Python 3.9 to 3.11.\n\n## ⭐️ Code Overview\n\n### Creating Video with Compositions\n\nSimilar to other video editing software,\nMovis employs the concept of *\"compositions\"* as the fundamental unit for video editing.\nWithin a composition, users can include multiple layers and manipulate\nthese layers' attributes over a time scale to produce a video.\nEffects can also be selectively applied to these layers as needed.\n\nHere's some example code:\n\n```python\nimport movis as mv\n\nscene = mv.layer.Composition(size=(1920, 1080), duration=5.0)\nscene.add_layer(mv.layer.Rectangle(scene.size, color='#fb4562'))  # Set background\n\npos = scene.size[0] // 2, scene.size[1] // 2\nscene.add_layer(\n    mv.layer.Text('Hello World!', font_size=256, font_family='Helvetica', color='#ffffff'),\n    name='text',  # The layer item can be accessed by name\n    offset=1.0,  # Show the text after one second\n    position=pos,  # The layer is centered by default, but it can also be specified explicitly\n    anchor_point=(0.0, 0.0),\n    opacity=1.0, scale=1.0, rotation=0.0,  # anchor point, opacity, scale, and rotation are also supported\n    blending_mode='normal')  # Blending mode can be specified for each layer.\nscene['text'].add_effect(mv.effect.DropShadow(offset=10.0))  # Multiple effects can be added.\nscene['text'].scale.enable_motion().extend(\n    keyframes=[0.0, 1.0], values=[0.0, 1.0], easings=['ease_in_out'])\n# Fade-in effect. It means that the text appears fully two seconds later.\nscene['text'].opacity.enable_motion().extend([0.0, 1.0], [0.0, 1.0])\n\nscene.write_video('output.mp4')\n```\n\nThe composition can also be used as a layer.\nBy combining multiple compositions and layers, users can create complex videos.\n\n```python\nscene2 = mv.layer.Composition(scene.size, duration=scene.duration)\nlayer_item = scene2.add_layer(scene, name='scene')\n# Equivalent to scene2['scene'].add_effect(...)\nlayer_item.add_effect(mv.effect.GaussianBlur(radius=10.0))\n```\n\n### Simple video processing\n\nOf course, movis also supports simple video processing such as video merging and trimming.\n\n#### concat\n\n```python\nintro = mv.layer.Video('intro.mp4')\ntitle = mv.layer.Video('title.mp4')\nchapter1 = mv.layer.Composition(size=(1920, 1080), duration=60.0)\n...\nmain = mv.concatenate([intro, title, chapter1, ...])\n```\n\n#### cutout\n\n```python\nraw_video = mv.layer.Video('video.mp4')\n# select 0.0-1.0 secs and 2.0-3.0 secs, and concatenate them\nvideo = mv.trim(raw_video, start_times=[0.0, 2.0], end_times=[1.0, 3.0])\n```\n\n#### cropping\n\n```python\nlayer = mv.layer.Image(\"image.png\", duration=1.0)\n# crop from x, y = (10, 20) with size w, h = (100, 200)\nlayer = mv.crop(layer, (10, 20, 100, 200))\n```\n\n#### resizing\n\n```python\nlayer = mv.layer.Video('video.mp4')\nwidth, height = layer.size\n\n# resize to 1/2\nmain = mv.layer.Composition(size=(width // 2, height // 2), duration=layer.duration)\nmain.add_layer(layer, scale=0.5)\n```\n\n#### fade-in / out\n\n```python\nlayer = mv.layer.Video('video.mp4')\nvideo1 = mv.fade_in(layer, 1.0)  # fade-in for 1.0 secs\nvideo2 = mv.fade_out(layer, 1.0)  # fade-out for 1.0 secs\nvideo3 = mv.fade_in_out(layer, 1.0, 2.0)  # fade-in for 1.0 secs and fade-out for 2.0 secs\n```\n\n### Implementation of custom layers, effects, and animations\n\nMovis is designed to make it easy for users to implement custom layers and effects.\nThis means that engineers can easily integrate their preferred visual effects and animations using Python.\n\nFor example, let's say you want to create a demo video using your own machine learning model for tasks\nlike anonymizing face images or segmenting videos.\nWith Movis, you can easily do this without the need for more complex languages like C++,\nby directly using popular libraries such as [PyTorch](https://pytorch.org/) or [Jax](https://github.com/google/jax).\nAdditionally, for videos that make use of GPGPU like [shader art](https://www.shadertoy.com/),\nyou can implement these intuitively through Python libraries like [Jax](https://github.com/google/jax) or [cupy](https://cupy.dev/).\n\nFor example, to implement a user-defined layer, you only need to create a function that, given a time,\nreturns an `np.ndarray` with a shape of `(H, W, 4)` and dtype of `np.uint8` in RGBA order, or returns `None`.\n\n```python\nimport numpy as np\nimport movis as mv\n\nsize = (640, 480)\n\ndef get_radial_gradient_image(time: float) -\u003e np.ndarray:\n    center = np.array([size[1] // 2, size[0] // 2])\n    radius = min(size)\n    inds = np.mgrid[:size[1], :size[0]] - center[:, None, None]\n    r = np.sqrt((inds ** 2).sum(axis=0))\n    p = 255 - (np.clip(r / radius, 0, 1) * 255).astype(np.uint8)\n    img = np.zeros((size[1], size[0], 4), dtype=np.uint8)\n    img[:, :, :3] = p[:, :, None]\n    img[:, :, 3] = 255\n    return img\n\nscene = mv.layer.Composition(size, duration=5.0)\nscene.add_layer(get_radial_gradient_image)\nscene.write_video('output.mp4')\n```\n\nIf you want to specify the duration of a layer,\nthe `duration` property is required. Movis also offers caching features\nto accelerate rendering. If you wish to speed up rendering for layers\nwhere the frame remains static, you can implement the `get_key(time: float)` method:\n\n```python\nclass RadialGradientLayer:\n    def __init__(self, size: tuple[int, int], duration: float):\n        self.size = size\n        self.duration = duration\n        self.center = np.array([size[1] // 2, size[0] // 2])\n    \n    def get_key(self, time: float) -\u003e Hashable:\n        # Returns 1 since the same image is always returned\n        return 1\n    \n    def __call__(self, time: float) -\u003e None | np.ndarray:\n        # ditto.\n```\n\n#### Custom effects\n\nEffects for layers can also be implemented in a similar straightforward manner.\n\n```python\nimport cv2\nimport movis as mv\nimport numpy as np\n\ndef apply_gaussian_blur(prev_image: np.ndarray, time: float) -\u003e np.ndarray:\n    return cv2.GaussianBlur(prev_image, (7, 7), -1)\n\nscene = mv.layer.Composition(size=(1920, 1080), duration=5.0)\nscene.add_layer(mv.layer.Rectangle(scene.size, color='#fb4562'))\nscene.add_layer(\n    mv.layer.Text('Hello World!', font_size=256, font_family='Helvetica', color='#ffffff'),\n    name='text')\nscene['text'].add_effect(apply_gaussian_blur)\n```\n\n#### User-defined animations\n\nAnimation can be set up on a keyframe basis, but in some cases,\nusers may want to animate using user-defined functions.\nmovis provides methods to handle such situations as well.\n\n```python\nimport movis as mv\nimport numpy as np\n\nscene = mv.layer.Composition(size=(1920, 1080), duration=5.0)\nscene.add_layer(\n    mv.layer.Text('Hello World!', font_size=256, font_family='Helvetica', color='#ffffff'),\n    name='text')\nscene['text'].position.add_function(\n    lambda prev_value, time: prev_value + np.array([0, np.sin(time * 2 * np.pi) * 100]),\n)\n```\n\n### Fast Prototyping on Jupyter Notebook\n\nJupyter notebooks are commonly used for data analysis that requires a lot of trial and error using Python.\nSome methods for Jupyter notebooks are also included in movis to speed up the video production process.\n\nFor example, ``composition.render_and_play()`` is often used to\npreview a section of a video within a Jupyter notebook.\n\n```python\nimport movis as mv\n\nscene = mv.layer.Composition(size=(1920, 1080), duration=10.0)\n... # add layers and effects...\nscene.render_and_play(\n    start_time=5.0, end_time=10.0, preview_level=2)  # play the video from 5 to 10 seconds\n```\n\nThis method has an argument called ``preview_level``.\nFor example, by setting it to 2, you can sacrifice video quality\nby reducing the final resolution to 1/2 in exchange for faster rendering.\n\nIf you want to reduce the resolution when exporting videos or still images using\n``composition.write_video()`` or similar methods,\nyou can use the syntax ``with composition.preview(level=2)``.\n\n```python\nimport movis as mv\n\nscene = mv.layer.Composition(size=(1920, 1080), duration=10.0)\n... # add layers and effects...\nwith scene.preview(level=2):\n    scene.write_video('output.mp4')  # The resolution of the output video is 1/2.\n    img = scene(5.0)  # retrieve an image at t = 5.0\nassert img.shape == (540, 960, 4)\n```\n\nWithin this scope, the resolution of all videos and images will be reduced to 1/2.\nThis can be useful during the trial and error process.\n\n## 📃 License\n\nMIT License (see `LICENSE` for details).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezoo%2Fmovis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frezoo%2Fmovis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezoo%2Fmovis/lists"}