Skip to content

Video editing with Python

`Colorclip` changed `col`>`color` (#424)

Gloin131301f207aa49b5
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 6a7a6c8e..73266242 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -10,6 +10,7 @@ import subprocess as sp
import multiprocessing
import tempfile
from copy import copy
+import warnings
from tqdm import tqdm
import numpy as np
@@ -1031,13 +1032,24 @@ class ColorClip(ImageClip):
ismask
Set to true if the clip will be used as a mask.
- """
+ col
+ Has been deprecated. Do not use.
+ """
- def __init__(self, size, col=(0, 0, 0), ismask=False, duration=None):
+ def __init__(self, size, color=None, ismask=False, duration=None, col=None):
+ if col is not None:
+ warnings.warn("The `ColorClip` parameter `col` has been deprecated."
+ " Please use `color` instead", DeprecationWarning)
+ if color is not None:
+ warnings.warn("The arguments `color` and `col` have both been "
+ "passed to `ColorClip` so `col` has been ignored.",
+ UserWarning)
+ else:
+ color = col
w, h = size
- shape = (h, w) if np.isscalar(col) else (h, w, len(col))
- ImageClip.__init__(self, np.tile(col, w * h).reshape(shape),
+ shape = (h, w) if np.isscalar(color) else (h, w, len(color))
+ ImageClip.__init__(self, np.tile(color, w * h).reshape(shape),
ismask=ismask, duration=duration)
diff --git a/tests/test_PR.py b/tests/test_PR.py
index cbb4f2d6..36583ae8 100644
--- a/tests/test_PR.py
+++ b/tests/test_PR.py
@@ -32,5 +32,15 @@ def test_PR_339():
#overlay = TextClip(txt='foo', method='label')
pass
+
+def test_PR_424():
+ # Recommended use
+ clip = ColorClip([1000, 600], color=(60, 60, 60), duration=10)
+ # Uses `col` so should work the same as above, but give warning
+ clip = ColorClip([1000, 600], col=(60, 60, 60), duration=10)
+ # Should give 2 warnings and use `color`, not `col`
+ clip = ColorClip([1000, 600], color=(60, 60, 60), duration=10, col=(2,2,2))
+
+
if __name__ == '__main__':
pytest.main()