MoviePy 动画文本

问题描述

我怎样才能让文本继续而不停在左侧? 我没有看到我使用的方法有问题。而且我认为我为动画使用了正确的公式。

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),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")

解决方法

代码在我使用时对我有用

res.cookie("jwt",token,{
  expires: new Date(
    Date.now() + process.env.JWT_COOKIE_EXPIRES_IN * 24 * 60 * 60 * 1000
  ),httpOnly: true,// cannot be modified by the browser
});

代替

 int(w - 0.5 * w * t)

所以 max(w/w,int(w - 0.5 * w * t)) 正在停止动画

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...