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

How can I include a moving 'arrow' in a clip? #762

Closed
Swiffers opened this issue Apr 11, 2018 · 7 comments
Closed

How can I include a moving 'arrow' in a clip? #762

Swiffers opened this issue Apr 11, 2018 · 7 comments

Comments

@Swiffers
Copy link

Swiffers commented Apr 11, 2018

I'm need to create and include inside my videos an animation with a moving arrow, like this

1. ->
2. -->
3.  -->
4.   -->
5.    -->
6.   -->
7.  -->
8. -->
9. ->

1 to 9 represents frames/or time.

What are your recommendations on how to do it ? For the moment my only idea would be to create an arrow image and add it using ImageClip('arrow.png') display it 1 second, move it 1 pixel, hide it, display it, etc.

Your advices are welcome

@Swiffers Swiffers changed the title How can I include a moving in a clip? How can I include a moving 'arrow' in a clip? Apr 11, 2018
@Swiffers
Copy link
Author

Is it possible to add transparent gif inside a clip? it's possible with ImageClip but would it keep the gif background transparency?

@Zulko
Copy link
Owner

Zulko commented Apr 12, 2018

You could do it using a composite video clip with an arrow whose position depends on time. Something like this:

final_clip = CompositeVideoClip([
    background_clip,
    arrow_clip.set_pos(lambda t: (300 + 20 * np.sin(t), 400))
]).set_duration(background_clip.duration)

where arrow_clip was loaded using Imageclip("my_arrow.png", has_mask=True).
Apologies for any syntax mistake. written in a hurry.

@Swiffers
Copy link
Author

@Zulko thanks. If I use a .gif with a transparent background and add it as an imageclip('') will it keep the transparency?

@Zulko
Copy link
Owner

Zulko commented Apr 12, 2018

cant remember exactly, certainly yes but you would need to say "with_alpha" or something when you load the GIF with VideoFileClip

@Swiffers
Copy link
Author

@Zulko I see withmask

will save the clip’s mask (if any) as an alpha canal (PNGs only)

But where is the option to load the GIF using VideoFileClip() with a transparent background ?

class moviepy.video.io.VideoFileClip.VideoFileClip(filename, has_mask=False, audio=True, audio_buffersize=200000, target_resolution=None, resize_algorithm='bicubic', audio_fps=44100, audio_nbytes=2, verbose=False, fps_source='tbr')

@Zulko
Copy link
Owner

Zulko commented Apr 13, 2018

has_mask ?

@Swiffers
Copy link
Author

Perfect.

Why is it called a mask? I'm new to video edition. I thought that a mask would be used to show a part of the video (i.e: the part under the mask).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants