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

CompositeVideoClip - Different rules for clip appereance #1162

Closed
Kaszanas opened this issue Apr 28, 2020 · 5 comments · Fixed by #1176
Closed

CompositeVideoClip - Different rules for clip appereance #1162

Kaszanas opened this issue Apr 28, 2020 · 5 comments · Fixed by #1176
Labels
feature-request Request for a new feature or additional functionality.

Comments

@Kaszanas
Copy link

I have stumbled upon this problem while coding a feature involving clips being sorted in a different manner than the one intended by the CompositeVideoClip.

What i mean by that is that usually while working with any video (outside of Python). You imagine the videos in layers where You would like to have different layers.

At this point every Video is in its own layer based on the index on the list [clip0, transition_clip, clip1], would make it that clip1 is cutting the transition_clip.

I haven't tested any workarounds. but I suspect that this might be solved by using Two CompositeVideoClips with two lists of clips with different .start_time() parameters.

That would mean using:

transition_clips = CompositeVideoClip([transition_clip, transition_clip, transition_clip])
legit_clips = CompositeVideoClip([clip0, clip1, clip2])

final_composition = CompositeVideoClip([legit_clips, transition_clips])

Which might not be computationally efficient at all as there are 3x nested clips.

Please note that the code shown above is not fully operational. I have ommited .set_start()

Which leads me to thing that this might be solved simply by sorting the lists somehow.

@tburrows13 tburrows13 added the feature-request Request for a new feature or additional functionality. label Apr 28, 2020
@tburrows13
Copy link
Collaborator

Hello, thank you for raising this.

I believe that everything you need is possible using only one CompositeVideoClip. You should be able to arrange the order of clips so that all the transition clips are at the end. The ordering is not used for time because you use clip.set_start() on each clip to set when it finishes.

However, I was thinking of adding a clip.set_z() (or similar) which would override the ordering of the list of clips passed into CompositeVideoClip(), so that it could use each clips z index when deciding which to put on top. Would that solve your problem better? I think that it would be a more robust solution than just using the order of the clips in a list.

@Kaszanas
Copy link
Author

Kaszanas commented May 1, 2020

@tburrows13 I feel like most of the time people coming from video editing industry think of compositing in terms of "layering" videos one on top of the other.

My suggested change would be to go with something like:
.set_layer() which would implicitly put everything into layer index = 0

but when user explicitly uses it:

list_of_video_clips = [clip0, clip1, clip2]
list_of_transition_clips = [transition_clip.set_layer(1) for video_clip in list_of_video_clips]

my_composite_video = CompositeVideoClip(list_of_video_clips + list_of_transition_clips)

I have purposely ommited any .set_time() as my goal is not to showcase full possible business logic used. but a possibility that this feature might get used.

Depends on how it works in the backend every layer could be initializing new array which would later be added to the end of existing array effectively introducing the feature.

@tburrows13 tburrows13 added this to the Release v2.0.0 milestone May 1, 2020
@tburrows13
Copy link
Collaborator

Ok, that makes a lot of sense. I don't know much about professional video editing, but I've come across layers before. Would you expect layer 2 to be 'on top of' layer 1, or the other way round?

It seems like it would be a fairly simple feature to add, it would just mean CompositeVideoClip sorting clips by layer inside of its __init__. I'll make sure it is included in v2.0, but I don't have time anytime soon, so anyone else is free to have a go first!

@Kaszanas
Copy link
Author

Kaszanas commented May 2, 2020

.set_layer(0) Would be the base layer if no layer is set explicitly.
Any other layer with higher argument supplied would mean they are on top.

.set_layer(1) Would be rendered on top of the .set_layer(0)

@tburrows13
Copy link
Collaborator

Implemented in #1176 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for a new feature or additional functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants