繁体   English   中英

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

[英]Displaying gif VideoClips on a half circle path with moviepy

我正在尝试在基本视频的基础上制作大约 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()

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM