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

Fix Freeze effect removing original start and end parameters #2339

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def with_start(self, t, change_end=True):
These changes are also applied to the ``audio`` and ``mask``
clips of the current clip, if they exist.

note::
The start and end attribute of a clip define when a clip will start
playing when used in a composite video clip, not the start time of
the clip itself.

i.e: with_start(10) mean the clip will still start at his first frame,
but if used in a composite video clip it will only start to show at
10 seconds.

Parameters
----------

Expand Down Expand Up @@ -248,6 +257,15 @@ def with_end(self, t):
(hour, min, sec), or as a string: '01:03:05.35'. Also sets the duration
of the mask and audio, if any, of the returned clip.

note::
The start and end attribute of a clip define when a clip will start
playing when used in a composite video clip, not the start time of
the clip itself.

i.e: with_start(10) mean the clip will still start at his first frame,
but if used in a composite video clip it will only start to show at
10 seconds.

Parameters
----------

Expand Down
14 changes: 13 additions & 1 deletion moviepy/video/fx/Freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ class Freeze(Effect):
With ``total_duration`` you can specify the total duration of
the clip and the freeze (i.e. the duration of the freeze is
automatically computed). One of them must be provided.

With ``update_start_end`` you can define if the effect must preserve
and/or update start and end properties of the original clip
"""

t: float = 0
freeze_duration: float = None
total_duration: float = None
padding_end: float = 0
update_start_end: bool = True

def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
Expand All @@ -40,4 +44,12 @@ def apply(self, clip: Clip) -> Clip:
before = [clip[: self.t]] if (self.t != 0) else []
freeze = [clip.to_ImageClip(self.t).with_duration(self.freeze_duration)]
after = [clip[self.t :]] if (self.t != clip.duration) else []
return concatenate_videoclips(before + freeze + after)

new_clip = concatenate_videoclips(before + freeze + after)
if self.update_start_end:
if clip.start is not None:
new_clip = new_clip.with_start(clip.start)
if clip.end is not None:
new_clip = new_clip.with_end(clip.end + self.freeze_duration)

return new_clip
3 changes: 2 additions & 1 deletion moviepy/video/io/ffmpeg_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ def ffmpeg_version():
cmd = [
FFMPEG_BINARY,
"-version",
"-v", "quiet",
"-v",
"quiet",
]

result = subprocess.run(cmd, capture_output=True, text=True, check=True)
Expand Down
Loading