Skip to main content

AI Image: Dưới đây là một ví dụ **mã Python đơn giản** để tạo video AI (kiểu slideshow + chữ + nhạc) về món **

Back to Gallery
Dưới đây là một ví dụ **mã Python đơn giản** để tạo video AI (kiểu slideshow + c
Image
flux-schnell
1024 x 1024

Prompt

Dưới đây là một ví dụ **mã Python đơn giản** để tạo video AI (kiểu slideshow + chữ + nhạc) về món **bún trộn thịt nướng** bằng thư viện `moviepy`. Bạn có thể thay đổi hình ảnh + nội dung theo ý muốn. --- ## 🔧 Cài đặt thư viện ```bash pip install moviepy ``` --- ## 🎬 Code tạo video ```python from moviepy.editor import * # Danh sách hình ảnh (bạn thay file của bạn) image = [ "bun1.jpg", "bun2.jpg", "bun3.jpg" ] # Nội dung text tương ứng text = [ "Bún trộn thịt thơm ngon", "Thịt vàng hấp dẫn", "Ăn kèm rau sống và nước mắm chua ngọt" ] clips = [] for i in range(len(images)): # Tạo clip ảnh img_clip = ImageClip(images[i]).set_duration(4) # Tạo text txt_clip = TextClip(text[i], fontize=50, color='white', bg_color='black', size=img_clip.size ).set_duration(4) # Ghép ảnh + text video = CompositeVideoClip([img_clip, txt_clip.set_position("bottom")]) clips.append(video) # Ghép các đoạn lại Final_video = concatenate_videoclips(clips, Method="compose") # Thêm nhạc nền (tuỳ chọn) audio = AudioFileClip("nhacnen.mp3").subclip(0, Final_video.duration) Final_video = Final_video.set_audio(audio) # Xuất video Final_video.write_videofile("bun_tron_thit_nuong.mp4", fps=24) ``` ---

Created April 4, 2026

Create Your Own Version

Use this prompt as inspiration or remix it into something new.

Back to Gallery