Skip to content

Video editing with Python

fix tests issues

osaajanie01053630e1b
diff --git a/tests/test_issues.py b/tests/test_issues.py
index eb99bbc8..5bbee443 100644
--- a/tests/test_issues.py
+++ b/tests/test_issues.py
@@ -4,12 +4,7 @@ import os
import pytest
-from moviepy.audio.io.AudioFileClip import AudioFileClip
-from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip, concatenate_videoclips
-from moviepy.video.compositing.transitions import crossfadein, crossfadeout
-from moviepy.video.fx.resize import resize
-from moviepy.video.io.VideoFileClip import VideoFileClip
-from moviepy.video.VideoClip import ColorClip, ImageClip, VideoClip
+from moviepy import *
try:
@@ -237,7 +232,7 @@ def test_issue_334(util):
tt = VideoFileClip("media/big_buck_bunny_0_30.webm").with_subclip(0, 3)
# TODO: Setting mask here does not work:
# .with_mask(maskclip).resize(size)])
- final = CompositeVideoClip([tt, concatenated.with_position(posi).fx(resize, size)])
+ final = CompositeVideoClip([tt, concatenated.with_position(posi).with_effects([vfx.Resize(size)])])
final.duration = tt.duration
final.write_videofile(os.path.join(util.TMP_DIR, "issue_334.mp4"), fps=10)
@@ -247,15 +242,7 @@ def test_issue_354():
clip.duration = 10
crosstime = 1
- # TODO: Should this be removed?
- # caption = editor.TextClip("test text", font="Liberation-Sans-Bold",
- # color='white', stroke_color='gray',
- # stroke_width=2, method='caption',
- # size=(1280, 720), font_size=60,
- # align='South-East')
- # caption.duration = clip.duration
-
- fadecaption = clip.fx(crossfadein, crosstime).fx(crossfadeout, crosstime)
+ fadecaption = clip.with_effects([vfx.CrossFadeIn(crosstime), vfx.CrossFadeOut(crosstime)])
CompositeVideoClip([clip, fadecaption]).close()
@@ -263,54 +250,8 @@ def test_issue_359(util):
with ColorClip((800, 600), color=(255, 0, 0)).with_duration(0.2) as video:
video.fps = 30
video.write_gif(
- filename=os.path.join(util.TMP_DIR, "issue_359.gif"), tempfiles=True
- )
-
-
[email protected](not matplotlib, reason="no matplotlib")
-def test_issue_368(util):
- import matplotlib.pyplot as plt
- import numpy as np
- from sklearn import svm
- from sklearn.datasets import make_moons
-
- from moviepy.video.io.bindings import mplfig_to_npimage
-
- plt.switch_backend("Agg")
-
- X, Y = make_moons(50, noise=0.1, random_state=2) # semi-random data
-
- fig, ax = plt.subplots(1, figsize=(4, 4), facecolor=(1, 1, 1))
- fig.subplots_adjust(left=0, right=1, bottom=0)
- xx, yy = np.meshgrid(np.linspace(-2, 3, 500), np.linspace(-1, 2, 500))
-
- def make_frame(t):
- ax.clear()
- ax.axis("off")
- ax.set_title("SVC classification", fontsize=16)
-
- classifier = svm.SVC(gamma=2, C=1)
- # the varying weights make the points appear one after the other
- weights = np.minimum(1, np.maximum(0, t**2 + 10 - np.arange(50)))
- classifier.fit(X, Y, sample_weight=weights)
- Z = classifier.decision_function(np.c_[xx.ravel(), yy.ravel()])
- Z = Z.reshape(xx.shape)
- ax.contourf(
- xx,
- yy,
- Z,
- cmap=plt.cm.bone,
- alpha=0.8,
- vmin=-2.5,
- vmax=2.5,
- levels=np.linspace(-2, 2, 20),
+ filename=os.path.join(util.TMP_DIR, "issue_359.gif")
)
- ax.scatter(X[:, 0], X[:, 1], c=Y, s=50 * weights, cmap=plt.cm.bone)
-
- return mplfig_to_npimage(fig)
-
- animation = VideoClip(make_frame, duration=0.2)
- animation.write_gif(os.path.join(util.TMP_DIR, "svm.gif"), fps=20)
def test_issue_407():
@@ -350,9 +291,8 @@ def test_issue_416():
def test_issue_417():
# failed in python2
cad = "media/python_logo.png"
- myclip = ImageClip(cad).fx(resize, new_size=[1280, 660])
+ myclip = ImageClip(cad).resized(new_size=[1280, 660])
CompositeVideoClip([myclip], size=(1280, 720))
- # final.with_duration(7).write_videofile("test.mp4", fps=30)
def test_issue_470(util):
@@ -386,7 +326,7 @@ def test_issue_547():
def test_issue_636():
with VideoFileClip("media/big_buck_bunny_0_30.webm").with_subclip(0, 11) as video:
- with video.subclip(0, 1) as _:
+ with video.with_subclip(0, 1) as _:
pass