Skip to content

Instantly share code, notes, and snippets.

@Seawed
Created April 1, 2023 19:56
Show Gist options
  • Save Seawed/2f7858a19574e3fb29627df6ea0e6204 to your computer and use it in GitHub Desktop.
Save Seawed/2f7858a19574e3fb29627df6ea0e6204 to your computer and use it in GitHub Desktop.
simple app to convert word[or text] to video.
import cv2
from moviepy.editor import *
import numpy as np
# Words - массив из слов на английском. Каждое слово - 1 кадр.
words = ['All', 'what', 'you', 'want', 'YOU', 'can', 'do', 'it']
# Создание изображений с надписями
images = []
for word in words:
img = np.zeros((1280, 1024, 3), np.uint8) # разрешение видео
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, word, (100, 500), font, 4, (255, 255, 255), 2, cv2.LINE_AA)
images.append(img)
# Создание видео из изображений
clips = [ImageClip(m).set_duration(0.3) for m in images]
video = concatenate_videoclips(clips)
# Добавление звуковой дорожки к видео
# audio = AudioFileClip("audio.mp3")
# video = video.set_audio(audio)
# Сохранение видео
video.write_videofile("output.mp4", fps=30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment