{"id":1562,"library":"moviepy","title":"MoviePy: Video Editing with Python","description":"MoviePy is a powerful, open-source Python library for video editing, compositing, and processing. It enables programmatic video manipulation, making it ideal for automating tasks like cutting, concatenating, adding effects, or creating custom animations. The current version is 2.2.1, and it maintains an active, though irregular, release cadence.","status":"active","version":"2.2.1","language":"en","source_language":"en","source_url":"https://github.com/Zulko/moviepy","tags":["video-editing","ffmpeg","multimedia","automation","video-processing"],"install":[{"cmd":"pip install moviepy","lang":"bash","label":"Core library"},{"cmd":"pip install moviepy[optional]","lang":"bash","label":"With recommended dependencies (imageio-ffmpeg, Pillow)"}],"dependencies":[{"reason":"MoviePy relies heavily on FFmpeg for video processing. FFmpeg binaries must be installed and accessible in your system's PATH, or its location specified via `FFMPEG_BINARY` environment variable. `imageio-ffmpeg` (an optional Python dependency) helps manage FFmpeg subprocesses.","package":"ffmpeg","optional":false},{"reason":"Recommended for robust FFmpeg integration and handling various video codecs.","package":"imageio-ffmpeg","optional":true},{"reason":"Used for image manipulation tasks within MoviePy (e.g., text clips, overlays).","package":"Pillow","optional":true},{"reason":"Fundamental for numerical operations on video frames.","package":"numpy","optional":false}],"imports":[{"note":"`moviepy.editor` is the high-level module providing most common functionalities. Direct imports from lower-level modules are generally discouraged for user-facing code.","wrong":"from moviepy.video.io.VideoFileClip import VideoFileClip","symbol":"VideoFileClip","correct":"from moviepy.editor import VideoFileClip"},{"symbol":"AudioFileClip","correct":"from moviepy.editor import AudioFileClip"},{"symbol":"concatenate_videoclips","correct":"from moviepy.editor import concatenate_videoclips"}],"quickstart":{"code":"from moviepy.editor import VideoFileClip, concatenate_videoclips, TextClip, CompositeVideoClip\n\ndef create_intro_outro(video_path='my_video.mp4'):\n    try:\n        clip = VideoFileClip(video_path)\n\n        intro_text = TextClip(\"My Awesome Video\", fontsize=70, color='white', bg_color='black')\\\n                        .set_duration(2).set_position('center')\n        outro_text = TextClip(\"Thanks for Watching!\", fontsize=50, color='yellow', bg_color='black')\\\n                         .set_duration(1.5).set_position('center')\n\n        # Ensure text clips match video resolution for smooth concatenation\n        intro_text = intro_text.set_fps(clip.fps).resize(newsize=clip.size)\n        outro_text = outro_text.set_fps(clip.fps).resize(newsize=clip.size)\n\n        final_clip = concatenate_videoclips([intro_text, clip, outro_text], method=\"compose\")\n        output_filename = video_path.replace('.mp4', '_with_intro_outro.mp4')\n        final_clip.write_videofile(output_filename, fps=clip.fps, threads=4)\n        print(f\"Video saved to {output_filename}\")\n\n        clip.close()\n        intro_text.close()\n        outro_text.close()\n        final_clip.close()\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Please ensure 'my_video.mp4' exists and FFmpeg is installed and in your PATH.\")\n\n# To run, ensure you have a video file named 'my_video.mp4' in the same directory\n# create_intro_outro()","lang":"python","description":"This quickstart demonstrates how to load a video, create text clips for an intro and outro, concatenate them with the original video, and export the result. It highlights using `VideoFileClip`, `TextClip`, and `concatenate_videoclips` from `moviepy.editor`. Remember to replace 'my_video.mp4' with an actual video file and ensure FFmpeg is correctly installed."},"warnings":[{"fix":"Install FFmpeg for your operating system (e.g., `brew install ffmpeg` on macOS, or download binaries for Windows/Linux). Verify installation by running `ffmpeg -version` in your terminal. For Python, `pip install imageio-ffmpeg` is highly recommended, as it helps manage FFmpeg processes but does not install the FFmpeg binaries themselves.","message":"MoviePy's core functionality relies on FFmpeg. You MUST have FFmpeg installed on your system and accessible in your environment's PATH. Without it, most video loading and saving operations will fail with 'OSError: MoviePy Error: the file `ffmpeg` could not be found.'","severity":"breaking","affected_versions":"All versions"},{"fix":"Optimize by processing smaller clips, applying resizing early (`clip.resize()`), setting `fps` and `threads` parameters in `write_videofile`, and using generators for long sequences. Always `close()` clips when done with them to release resources, especially in loops.","message":"Processing large video files can be extremely memory-intensive and slow. MoviePy often loads frames into memory, leading to out-of-memory errors or very long processing times on longer or high-resolution videos.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure source videos are constant frame rate (CFR) if possible. When writing, try different codecs or explicitly setting audio parameters. For difficult cases, you might need to extract audio, process video, and then remux them separately (e.g., using FFmpeg directly or with `clip.set_audio(AudioFileClip('path_to_audio.mp3'))`).","message":"Audio and video synchronization issues can occur, especially with variable frame rate (VFR) source videos or after complex edits. Output files might have desynchronized audio.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official MoviePy 2.x documentation for the most up-to-date API. Prioritize imports from `moviepy.editor` as it's the stable high-level interface. For specific changes, consult the MoviePy changelog.","message":"Several modules and functions were restructured or deprecated between MoviePy 1.0 and 2.x (e.g., `moviepy.video.tools.cuts`). While many core functionalities remain similar, older tutorials or code snippets might use deprecated paths or methods.","severity":"deprecated","affected_versions":"Versions <= 1.x migrating to 2.x"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}