Skip to content

Commit

Permalink
Merge pull request #2339 from OsaAjani/fix-issue-2334
Browse files Browse the repository at this point in the history
Fix Freeze effect removing original start and end parameters
  • Loading branch information
OsaAjani authored Jan 22, 2025
2 parents b65a0c9 + 0b74192 commit dd873ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
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

0 comments on commit dd873ca

Please sign in to comment.