Skip to content

fix AttributeError on CompositeVideoClip with non-composite mask#2554

Open
Mr-Neutr0n wants to merge 1 commit intoZulko:masterfrom
Mr-Neutr0n:fix-composite-precomputed-attr
Open

fix AttributeError on CompositeVideoClip with non-composite mask#2554
Mr-Neutr0n wants to merge 1 commit intoZulko:masterfrom
Mr-Neutr0n:fix-composite-precomputed-attr

Conversation

@Mr-Neutr0n
Copy link
Copy Markdown

When you set a mask on a CompositeVideoClip that isn't itself a CompositeVideoClip (e.g. created via to_mask()), calling frame_function crashes with AttributeError: 'CompositeVideoClip' object has no attribute 'precomputed'.

The precomputed dict only gets created on CompositeVideoClip instances where is_mask=True and memoize_mask=True (in __init__). But frame_function unconditionally accesses self.mask.precomputed when self.mask and self.memoize_mask are truthy, without checking whether the mask object actually has that attribute.

The fix just adds a hasattr guard so we only try to memoize when the mask supports it.

Fixes #2514

CompositeVideoClip.frame_function accesses self.mask.precomputed
without checking if the mask actually has this attribute. The
precomputed dict is only set on CompositeVideoClip instances where
is_mask=True and memoize_mask=True, so using a regular VideoClip as
a mask (e.g. via to_mask()) causes an AttributeError.

Added a hasattr guard before accessing self.mask.precomputed.

Fixes Zulko#2514
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

Successfully merging this pull request may close these issues.

'CompositeVideoClip' object has no attribute 'precomputed'

1 participant