Transparency with CompositeVideoClip issue #2329
Replies: 7 comments
-
Hi, can you upload the result to be easier to understand the error, or just a link to the video? I think maybe you are writing the animated_image to manually check the alpha layer, but you can use it directly without writing it using Also, if this helps you, a frame is just a numpy array. If it has no mask, the frame has 3 values from 0 to 255 (RGB). If there is a mask, the frame has 4 values, the same 3 first are from 0 to 255 (RGB = color) and the last one from 0 to 1 (A = alpha layer). You could modify it directly with numpy instead of PIL if you know how to. |
Beta Was this translation helpful? Give feedback.
-
Ideally a video of the expected result and the actual result would be a big help. |
Beta Was this translation helpful? Give feedback.
-
here's a detailed explanaition :
the transparent layer was added successfuly and here is the output: then i have applied the Zoom Function :
and the test was successfuly done, here's the link :
after writing the video i found that the image is beign cropped and avoiding the transparent layer |
Beta Was this translation helpful? Give feedback.
-
Ok, thank you for your links. First I detect is one thing. Your zoom effect is actually applying a zoom on the image by manipulating the pixels but keeping the same frame size (as you do here I've downloaded your second link and when playing locally I can see that the image size is still the same (I rounded 2 corners) even when the image is aparently zooming. I don't know why the image is apparently zooming, I haven't work too much with ImageClips individually nor with the specific codec and preset you use for rendering. Maybe one expert can help you (us) with it. So, when you put the image in front of the background, as the image is always having the same size because you are forcing the frame to it (as I told you in the 2nd paragraph), the content is zoomed (as your zoom code does) but the size is the same. You are not zooming a clip. The result you want for your video is resizing the ImageClip, or resizing each frame of the clip (but not keeping the image). You can put the image as it is, make it an You know the video def resize_progressively(t, duration):
return 1 + 0.5 * t / duration
video.resized(lambda t: resize_progressively(t, video.duration)
"""
This, that is apparently complicated, is telling the video its size
(as a clip) for each time it is rendering one of its frames. The 't'
is the time moment for the current frame. Imagine a video of
duration=1s and fps=30. For frame 0, t=0, for frame 6, t=6/30
=> t=0.2. For frame 29, t=29/30 => t=0.966...7.
1 + 0.5 * 0 / 1 = 1, but 1 + 0.5 * 0.966...7 ~ 1.5. Also, as you see,
the progression is not perfect, you have to adjust it, this is just
a quick example.
""" I hope this clearifies something. Playing with moviepy is very funny and powerfull :) (you can see this if you don't trust me #2119 (comment)) |
Beta Was this translation helpful? Give feedback.
-
thanks for your help , it was really appreciated
in this function where i add the transparent layer it applies an alpha channel mask that is static to the initial image size i tried to change the mask but i'm very confused about how many similiar variables are there if you could help me will be very appreciated |
Beta Was this translation helpful? Give feedback.
-
Ok, let me introduce you to the incredible world of video masks, haha. A So, So, you usually attach a mask to a Now that you know the idea, you need to build your own :) |
Beta Was this translation helpful? Give feedback.
-
Hi guys, as this is more an in-depth dive into moviepy than an issue strictly speaking, I will move that to discussion where it will be easier to go back and forth ! |
Beta Was this translation helpful? Give feedback.
-
i used this function for zooming
with this as the main code
to get an image with smooth zooming as a foreground pic
with a background video
but the image is still being cropped even after i added a transparent layer to avoid cropping
here's how i added the transparent layer
the "test.mov" video is worked fine without any issues but after combining it with the background video using the composite i causes the cropping issue
Beta Was this translation helpful? Give feedback.
All reactions