Skip to content

Video editing with Python

Fix issue, remove old and bad tests, fix current test to trigger error with old code

osaajanid3528be9488c
diff --git a/moviepy/Clip.py b/moviepy/Clip.py
index 871ed8e3..e931f555 100644
--- a/moviepy/Clip.py
+++ b/moviepy/Clip.py
@@ -652,7 +652,7 @@ class Clip:
if key.step < 0:
# time mirror
clip = clip.time_transform(
- lambda t: clip.duration - t - 1,
+ lambda t: clip.duration - t - 1 / self.fps,
keep_duration=True,
apply_to=apply_to,
)
diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.py
index 41de8414..8f6835aa 100644
--- a/moviepy/video/io/ffmpeg_reader.py
+++ b/moviepy/video/io/ffmpeg_reader.py
@@ -476,12 +476,12 @@ class FFmpegInfosParser:
# for default streams, set their numbers globally, so it's
# easy to get without iterating all
if self._current_stream["default"]:
- self.result[f"default_{stream_type_lower}_input_number"] = (
- input_number
- )
- self.result[f"default_{stream_type_lower}_stream_number"] = (
- stream_number
- )
+ self.result[
+ f"default_{stream_type_lower}_input_number"
+ ] = input_number
+ self.result[
+ f"default_{stream_type_lower}_stream_number"
+ ] = stream_number
# exit chapter
if self._current_chapter:
diff --git a/tests/test_fx.py b/tests/test_fx.py
index 746b8491..f7a6e75e 100644
--- a/tests/test_fx.py
+++ b/tests/test_fx.py
@@ -1057,7 +1057,17 @@ def test_time_mirror():
def test_time_symmetrize():
- clip = BitmapClip([["AA", "AA"], ["BB", "BB"], ["CC", "CC"]], fps=1)
+ clip = BitmapClip(
+ [
+ ["AA", "AA"],
+ ["BB", "BB"],
+ ["CC", "CC"],
+ ["DD", "DD"],
+ ["EE", "EE"],
+ ["FF", "FF"],
+ ],
+ fps=2,
+ )
clip1 = clip.with_effects([vfx.TimeSymmetrize()])
target1 = BitmapClip(
@@ -1065,6 +1075,12 @@ def test_time_symmetrize():
["AA", "AA"],
["BB", "BB"],
["CC", "CC"],
+ ["DD", "DD"],
+ ["EE", "EE"],
+ ["FF", "FF"],
+ ["FF", "FF"],
+ ["EE", "EE"],
+ ["DD", "DD"],
["CC", "CC"],
["BB", "BB"],
["AA", "AA"],
diff --git a/tests/test_videotools.py b/tests/test_videotools.py
index 52c4e24a..4a1db9a3 100644
--- a/tests/test_videotools.py
+++ b/tests/test_videotools.py
@@ -283,10 +283,10 @@ def test_FramesMatches_best(n, percent, expected_result):
0,
FramesMatches(
[
- FramesMatch(0.08, 2.92, 0, 0),
- FramesMatch(0.2, 2.8, 0, 0),
- FramesMatch(0.32, 2.68, 0, 0),
- FramesMatch(0.44, 2.56, 0, 0),
+ FramesMatch(0.52, 3.44, 0, 0),
+ FramesMatch(0.6400, 3.3200, 0.0000, 0.0000),
+ FramesMatch(0.7600, 3.2000, 0.0000, 0.0000),
+ FramesMatch(0.9200, 3.0400, 0.0000, 0.0000),
]
),
id="(media/chaplin.mp4)(1, 3).fx(time_mirror)",
@@ -317,6 +317,7 @@ def test_FramesMatches_select_scenes(
assert result == expected_result
def test_FramesMatches_write_gifs(util):
video_clip = VideoFileClip("media/chaplin.mp4").subclipped(0, 0.2)
clip = concatenate_videoclips(