gpt4 book ai didi

python - 使用moviepy在半圆路径上显示gif VideoClips

转载 作者:行者123 更新时间:2023-12-04 23:09:49 25 4
gpt4 key购买 nike

我正在尝试在基本视频的基础上制作大约 6 到 7 个 gif 动画剪辑的集合。这些动画图标显示在视频中心的半圆上。我正在寻找编写此逻辑的最佳方法,但在此停留了一段时间。任何帮助深表感谢。

positions = [
[(200,200)],
[(200,300)],
[(200,400)],
[(200,500)],
[(200,600)],
[(200,700)],
[(200,800)],
[(200,900)],
[(200,1000)]

]

clip = (VideoFileClip(f"{DIRECTORY+wd}.gif")
.set_start(0)
.set_duration(video_clip.duration)
.set_position(positions[l]))
clips.append(clip)


final_clip = concatenate_videoclips([clips[i] for i in range(len(clips))])

最佳答案

我不知道我是否理解您尝试做的事情,但应该是

positions = [
(200, 200),
(200, 300),
(200, 400),
(200, 500),
(200, 600),
(200, 700),
(200, 800),
(200, 900),
(200, 1000)
]

clips = []

for pos in positions:
clip = (VideoFileClip(f"{DIRECTORY+wd}.gif")
.set_start(0)
.set_duration(video_clip.duration)
.set_position(pos))
clips.append(clip)

final_clip = concatenate_videoclips(clips)

编辑:
如果你想在圆形路径上绘制,那么你可能需要使用 sin() , cos()计算位置。
我用了 matplotlib显示位置。
它为半径为 10 的圆和中心 (50,50) 计算 36 个位置(每 10 度)
from math import sin, cos, radians

positions = []

r = 10
center_x = 50
center_y = 50

for angle in range(0, 360, 10):
x = center_x + sin(radians(angle)) * r
y = center_y + cos(radians(angle)) * r
positions.append( (x, y) )

# ---

import matplotlib.pyplot as plt

data_x = [pos[0] for pos in positions]
data_y = [pos[1] for pos in positions]

plt.scatter(data_x, data_y)
plt.show()
enter image description here

关于python - 使用moviepy在半圆路径上显示gif VideoClips,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72730989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com