[英]MoviePy animated text
我怎樣才能讓文本繼續而不停在左側? 我沒有看到我使用的方法有問題。 我認為我為動畫使用了正確的公式。
from moviepy.editor import *
# Load video
video = VideoFileClip("auto.mp4")
# Video lenght
duration = video.duration
# Video size
w, h = video.size
# Load text from txt
f = open('data.txt', 'r')
data = f.read().replace('\n', '')
# Text for video
txt = (TextClip(data, fontsize=50, font='Amiri-regular',
color='white')
.set_duration(duration))
# Transparent text background
txt_col = txt.on_color(size=(video.w + txt.w, txt.h - 10),
color=(0, 0, 0), pos=(6, 'center'), col_opacity=0.8)
# Animate text
txt_mov = txt_col.set_pos(lambda t: (max(w / w, int(w - 0.5 * w * t)),
max(5.4 * h / 6, int(0 * t))))
# Overlay text on video
result = CompositeVideoClip([video, txt_mov])
# Render video
result.write_videofile("test.mp4")
當我使用時,代碼對我有用
int(w - 0.5 * w * t)
代替
max(w/w, int(w - 0.5 * w * t))
所以max(w/w, ...)
正在停止動畫
試試這個你會喜歡它:#forticker remove -0.2
最大(w / 2.5, int(-0.2 * w * t)),
最大(h * 4 / 10, int(10 * t)))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.