Untitled
from moviepy.editor import TextClip, concatenate_videoclips def create_text_clip(text, duration, font_size=50, font="Arial-Bold"): """ Creates a text clip for the video. """ return TextClip( text, fontsize=font_size, color='white', bg_color='black', size=(1280, 720), font=font ).set_duration(duration) # Define the text and duration for each scene scenes = [ ("In a small village surrounded by mountains, there was a magical river named Lumina.", 5), ("Lumina could reflect the truth about a person's heart. Few dared to visit it.", 5), ("One day, three siblings—Aarav, Maya, and Kabir—visited Lumina, each with a purpose.", 6), ("Aarav sought wisdom, Maya wanted to prove her kindness, and Kabir desired riches.", 6), ("To see the truth, Lumina asked them to offer something precious.", 5), ("Aarav offered a book from his late mentor, and Maya offered a necklace she cherished.", 6), ("Kabir, reluctant to part with his wealth, offered a simple coin.", 5), ("The river showed Aarav sharing knowledge and uplifting the village.", 5), ("It showed Maya spreading kindness and joy among the villagers.", 5), ("But Kabir saw himself hoarding gold, lonely and unhappy.", 5), ("Years passed. Aarav became a wise teacher, and Maya, a beacon of kindness.", 6), ("Kabir grew rich but lonely, his greed pushing everyone away.", 5), ("Finally, Kabir returned to Lumina, offering his most prized possession.", 5), ("This time, Lumina showed him true wealth: happiness and relationships.", 6), ("Kabir changed his ways and began living with gratitude and generosity.", 5), ("Moral: True wealth lies in wisdom, kindness, and gratitude—not material possessions.", 6) ] # Create text clips for each scene text_clips = [create_text_clip(scene[0], scene[1]) for scene in scenes] # Combine all text clips into one video final_clip = concatenate_videoclips(text_clips, method="compose") # Output the video to a file output_path = "river_of_choices.mp4" final_clip.write_videofile(output_path, fps=24, codec="libx264") print(f"Video created successfully: {output_path}")
Leave a Comment