Certainly! Below is a Python script that generates a simple, visually satisfying YouTube Shorts-style video (vertical, <60s) using MoviePy and Pillow. The script creates a short animation of colorful, smoothly morphing shapes—something commonly seen in "satisfying" shorts. The video is saved as an MP4 file; it is not uploaded anywhere.
Requirements:
bash
pip install moviepy pillow numpy
python
import numpy as np
from PIL import Image, ImageDraw
from moviepy.editor import VideoClip
# Video settings
WIDTH, HEIGHT = 1080, 1920 # 9:16 aspect ratio for Shorts
DURATION = 15 # seconds
FPS = 30
def draw_morphing_shape(t, width, height):
"""Draws a morphing blob shape at time t."""
img = Image.new("RGB", (width, height), (30, 30, 40))
draw = ImageDraw.Draw(img)
# Blob parameters
cx, cy = width // 2, height // 2
base_radius = min(width, height) // 4
points = []
num_points = 8
for i in range(num_points):
angle = 2 * np.pi * i / num_points
# Animate the radius for each point
offset = np.sin(t * 2 + i + np.sin(t + i)) * 60
r = base_radius + offset
x = cx + int(np.cos(angle) * r)
y = cy + int(np.sin(angle) * r)
points.append((x, y))
# Animate color
r = int(120 + 80 * np.sin(t))
g = int(120 + 80 * np.sin(t + 2))
b = int(200 + 40 * np.sin(t + 4))
color = (r, g, b)
# Draw the blob
draw.polygon(points, fill=color)
# Optionally, add a soft glow
for i in range(1, 5):
alpha = int(80 / i)
glow_color = (r, g, b, alpha)
glow_img = Image.new("RGBA", (width, height), (0, 0, 0, 0))
glow_draw = ImageDraw.Draw(glow_img)
expanded_points = [
(
cx + int((x - cx) * (1 + 0.03 * i)),
cy + int((y - cy) * (1 + 0.03 * i))
)
for (x, y) in points
]
glow_draw.polygon(expanded_points, fill=glow_color)
img = Image.alpha_composite(img.convert("RGBA"), glow_img).convert("RGB")
return np.array(img)
def make_frame(t):
return draw_morphing_shape(t, WIDTH, HEIGHT)
if __name__ == "__main__":
clip = VideoClip(make_frame, duration=DURATION)
clip = clip.set_fps(FPS)
clip.write_videofile("satisfying_short.mp4", codec="libx264", audio=False)
What this does:
Generates a 15-second, 1080x1920 vertical video of a morphing, glowing blob.
The animation is smooth and visually pleasing, suitable for a "satisfying" short.
The video is saved as satisfying_short.mp4 in the current directory.
You can customize:
The shape, color, and animation logic in draw_morphing_shape.
The duration, resolution, and FPS.
No YouTube upload is performed.
Let me know if you want more complex effects or audio!
User
I get an error:
ModuleNotFoundError: No module named 'moviepy.editor'
I have moviepy v2.1.2
Assistant
That error suggests that the moviepy package is installed, but the editor submodule is missing or not found. This is unusual, as moviepy.editor is a standard part of MoviePy.
Let's troubleshoot:
1. Double-check your installation
First, ensure you are using the correct Python environment. Run:
bash
python -m pip show moviepy
You should see output like:
code
Name: moviepy
Version: 2.1.2
...
2. Try importing in Python shell
Open a Python shell and try:
python
import moviepy
import moviepy.editor
If the second line fails, your installation is broken or incomplete.
3. Reinstall MoviePy
Try reinstalling:
bash
pip uninstall moviepy
pip install moviepy
4. Check for file conflicts
Sometimes, a file named moviepy.py in your working directory can shadow the real package. Make sure there is no file named moviepy.py or a folder named moviepy in your script's directory.
5. Use the correct import
For MoviePy v2.x, the import should still be:
python
from moviepy.editor import VideoClip
If you still get the error, try:
python
import moviepy
print(moviepy.__file__)
This will show you where MoviePy is being imported from. If it's not from your site-packages, you have a conflict.
6. Alternative: Use moviepy.video.io.VideoFileClip
If for some reason moviepy.editor is not available, you can try importing directly:
python
from moviepy.video.VideoClip import VideoClip
But this is not standard and suggests a broken install.
Summary
Check for local file conflicts.
Reinstall MoviePy.
Use the standard import:
python
from moviepy.editor import VideoClip
Ensure your environment is correct.
If you still have issues, please paste the full error traceback and the output of: