Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pos and See VideoClip.set_pos for more details #2396

Open
nippotam opened this issue Mar 13, 2025 · 2 comments
Open

Pos and See VideoClip.set_pos for more details #2396

nippotam opened this issue Mar 13, 2025 · 2 comments
Labels
question Questions regarding functionality, usage

Comments

@nippotam
Copy link

nippotam commented Mar 13, 2025

I have a question regarding this attribute pos in

Impossible to use it and impossible to find "VideoClip.set_pos" details.

I want to put my clip at the center of a bigger frame

pos
A function t->(x,y) where x,y is the position of the clip when it is composed with other clips. See VideoClip.set_pos for more details

i tried this

clip = clip.pos(("center", "center"))

and also

clip = clip.pos((100, 100))

the error :

Traceback (most recent call last):
File "/Code_Diaporama/create_slideshow.py", line 100, in
create_slideshow(
File "/Code_Diaporama/create_slideshow.py", line 75, in create_slideshow
final_video = CompositeVideoClip(clips)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Code_Diaporama/.venv/lib/python3.11/site-packages/moviepy/video/compositing/CompositeVideoClip.py", line 98, in init
self.clips = sorted(self.clips, key=lambda clip: clip.layer_index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Code_Diaporama/.venv/lib/python3.11/site-packages/moviepy/video/compositing/CompositeVideoClip.py", line 98, in
self.clips = sorted(self.clips, key=lambda clip: clip.layer_index)
^^^^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'layer_index'

@nippotam nippotam added the question Questions regarding functionality, usage label Mar 13, 2025
@Implosiv3
Copy link
Contributor

Implosiv3 commented Mar 15, 2025

Which version are you using? As you can see in the error, your variable clip is no longer a clip, but a tuple. This is because the .pos(...) is returning a tuple with a (x, y) position. If you want to get the clip positioned, you should use clip = clip.with_position(...), in recent versions the names have been refactored so with_position is more intuitive.

@nippotam
Copy link
Author

nippotam commented Mar 15, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions regarding functionality, usage
Projects
None yet
Development

No branches or pull requests

2 participants