Issue
I am trying to compose a collection of about 6 to 7 gif aniated clips on top of a base video. These animated icons are shown on along a half circle at the center of the video. I am figuring out the best way to write this logic, but stuck at this for a while. Any help is much appreciated.
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))])
Solution
I don't know if I understand what you try to do but it should be rather
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)
EDIT:
And if you want to draw on circle path then you may need to use sin()
, cos()
to calculate positions.
I used matplotlib
to display positions.
It calculates 36 positions (every 10 degrees) for circle with radius 10, and center (50,50)
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()
Answered By - furas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.