Skip to content

Audio Challenge Press Play to listen. Which option is the odd animal out? Enter the number of your answer in the box below, then press Enter or the Done button below. #10

@sumitkunwar52-jpg

Description

@sumitkunwar52-jpg

from PIL import Image, ImageDraw, ImageFont
from moviepy.editor import ImageClip, concatenate_videoclips, CompositeVideoClip, TextClip
import numpy as np
from moviepy.config import change_settings
import os

img_path = "/mnt/data/RAKSHAAM.jpeg"

Load base image

base = Image.open(img_path).convert("RGB")

Create slides with promotional text

slides = []

texts = [
("RAKSHAAM SEEDS", "उपज सबसे ज्यादा"),
("BHAWANA", "120 से 125 दिन | संकर धान"),
("THETHAR", "125 से 130 दिन | बेहतरीन उत्पादन"),
("KUMKUM", "120 से 125 दिन | भरोसेमंद गुणवत्ता"),
("KARMA", "115 से 120 दिन | तेज़ और मजबूत फसल"),
("रक्षाम का वादा", "हर किसान की पहली पसंद")
]

Try loading fonts

try:
font_title = ImageFont.truetype("DejaVuSans-Bold.ttf", 48)
font_sub = ImageFont.truetype("DejaVuSans.ttf", 34)
except:
font_title = ImageFont.load_default()
font_sub = ImageFont.load_default()

for title, sub in texts:
frame = base.copy()
overlay = Image.new("RGBA", frame.size, (0, 0, 0, 0))
draw = ImageDraw.Draw(overlay)

# Bottom translucent banner
banner_h = 180
draw.rectangle(
    [(0, frame.height - banner_h), (frame.width, frame.height)],
    fill=(0, 80, 0, 190)
)

draw.text((40, frame.height - 150), title, font=font_title, fill="white")
draw.text((40, frame.height - 85), sub, font=font_sub, fill="yellow")

combined = Image.alpha_composite(frame.convert("RGBA"), overlay).convert("RGB")
slides.append(np.array(combined)) loop

Create video clips

clips = [ImageClip(slide).set_duration(3).fadein(0.5).fadeout(0.5) for slide in slides]

final = concatenate_videoclips(clips, method="compose")

output_path = "/mnt/data/rakshaam_promo_video.mp4"
final.write_videofile(output_path, fps=24, codec="libx264", audio=False)

print(f"Video saved at: {output_path}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions