我怎样才能让文本继续,而不是停在左边?我看不出我使用的方法有什么问题。我想我在动画中使用了正确的公式。
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")发布于 2021-07-11 07:02:26
代码在我使用
int(w - 0.5 * w * t)而不是
max(w/w, int(w - 0.5 * w * t))所以max(w/w, ...)停止了动画
发布于 2021-10-26 23:55:02
试试这个,你会喜欢的:
#for ticker remove -0.2
max(w / 2.5, int(-0.2 * w * t)),
max(h * 4 / 10, int(10 * t)))https://stackoverflow.com/questions/68331929
复制相似问题