-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed as not planned
Labels
Description
Bug report
Bug description:
# Add a code block here, if required
```from moviepy.editor import *
from PIL import Image, ImageDraw, ImageFont
import numpy as np
import random
# === НАСТРОЙКИ ===
base_image_path = "tim_ava.png" # твой фон (замени на путь к "тим ава.png")
output_video_path = "shapka_final.mp4"
W, H = 1280, 720 # разрешение ролика
font_path = "DejaVuSans-Bold.ttf" # путь к шрифту (можно любой TTF)
# === ФУНКЦИИ ===
def make_text_frame(text, fontsize, color, stroke=None, alpha=255):
img = Image.new("RGBA", (W, H), (0, 0, 0, 0))
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(font_path, fontsize)
w, h = draw.textsize(text, font=font)
x, y = (W-w)//2, (H-h)//2
if stroke:
for dx in range(-stroke, stroke+1):
for dy in range(-stroke, stroke+1):
if dx != 0 or dy != 0:
draw.text((x+dx, y+dy), text, font=font, fill=(0,0,0,alpha))
draw.text((x,y), text, font=font, fill=color+(alpha,))
return np.array(img.convert("RGB"))
# === КАДРЫ ===
def intro_frame(t):
alpha = int(255 * min(1, t/2))
return make_text_frame("Нету денег, когда они так нужны?", 60, (255,255,255), stroke=2, alpha=alpha)
def logo_frame(t):
r = 255
g = 150 + int(100*np.sin(t*8))
b = random.randint(0,40)
return make_text_frame("SHAPKA", 120, (r,g,b), stroke=4, alpha=255)
def money_frame(t):
img = Image.new("RGBA", (W,H), (0,0,0,0))
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(font_path, 50)
for i in range(40):
x = random.randint(0, W-40)
y = int((t*200 + random.randint(0,H)) % H)
draw.text((x,y), "$", font=font, fill=(0,255,0,200))
return np.array(img.convert("RGB"))
def final_frame(t):
alpha = int(255 * min(1, t/1.5))
return make_text_frame("Тебе к нам!", 80, (255,255,255), stroke=3, alpha=alpha)
# === КЛИПЫ ===
intro_clip = VideoClip(intro_frame, duration=3)
logo_clip = VideoClip(logo_frame, duration=2).set_start(3)
money_clip = VideoClip(money_frame, duration=5).set_start(5)
final_clip = VideoClip(final_frame, duration=2).set_start(10)
# Фон
bg_clip = ImageClip(base_image_path).resize((W,H)).set_duration(12)
# === СБОРКА ===
final = CompositeVideoClip([bg_clip, intro_clip, logo_clip, money_clip, final_clip])
final.write_videofile(output_video_path, fps=24, codec="libx264", audio=False)
### CPython versions tested on:
3.14
### Operating systems tested on:
Windows