You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from moviepy.editor import ImageClip, VideoFileClip, CompositeVideoClip
filepath = 'server/media/24d9adba48c588111e072939dc47227bb1ec23f8.mp4'
mark = 'media/img/logo.png'
vclip = VideoFileClip(filepath)
iclip = ImageClip(mark, duration=vclip.duration).set_pos(
('right', 'bottom', )
)
final = CompositeVideoClip([vclip, iclip])
final.write_videofile('/tmp/test.mp4')
Everything works great. But if I add unicode_literals:
from __future__ import unicode_literals
from moviepy.editor import ImageClip, VideoFileClip, CompositeVideoClip
filepath = 'server/media/24d9adba48c588111e072939dc47227bb1ec23f8.mp4'
mark = 'media/img/logo.png'
vclip = VideoFileClip(filepath)
iclip = ImageClip(mark, duration=vclip.duration).set_pos(
('right', 'bottom', )
)
final = CompositeVideoClip([vclip, iclip])
final.write_videofile('/tmp/ttt.mp4')
Script crashes with traceback:
Traceback (most recent call last):
File "1.tmp", line 8, in <module>
iclip = ImageClip(mark, duration=vclip.duration).set_pos(
File ".../lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 897, in __init__
if len(img.shape) == 3: # img is (now) a RGB(a) numpy array
AttributeError: 'unicode' object has no attribute 'shape'
If I prepend 'media/img/logo.png' with 'b': b'media/img/logo.png', then stacktrace change to:
[MoviePy] >>>> Building video /tmp/ttt.mp4
[MoviePy] Writing video /tmp/ttt.mp4
0%| | 0/157 [00:00<?, ?it/s]Traceback (most recent call last):
File "1.py", line 16, in <module>
final.write_videofile('/tmp/ttt.mp4')
File "<decorator-gen-51>", line 2, in write_videofile
File "...lib/python2.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-50>", line 2, in write_videofile
File "...lib/python2.7/site-packages/moviepy/decorators.py", line 137, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-49>", line 2, in write_videofile
File "...lib/python2.7/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "...lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 339, in write_videofile
ffmpeg_params=ffmpeg_params)
File "...lib/python2.7/site-packages/moviepy/video/io/ffmpeg_writer.py", line 204, in ffmpeg_write_video
fps=fps, dtype="uint8"):
File "...lib/python2.7/site-packages/tqdm/_tqdm.py", line 459, in __iter__
for obj in iterable:
File "...lib/python2.7/site-packages/moviepy/Clip.py", line 473, in generator
frame = self.get_frame(t)
File "<decorator-gen-14>", line 2, in get_frame
File "...lib/python2.7/site-packages/moviepy/decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "...lib/python2.7/site-packages/moviepy/Clip.py", line 95, in get_frame
return self.make_frame(t)
File "...lib/python2.7/site-packages/moviepy/video/compositing/CompositeVideoClip.py", line 110, in make_frame
f = c.blit_on(f, t)
File "...lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 569, in blit_on
pos = map(int, pos)
ValueError: invalid literal for int() with base 10: 'right'
Workaround to last stacktrace is to prepend 'right' and 'bottom' with 'b': (b'right', b'bottom', )
I've found similar issue, but not exactly the same #76
I can try to fix it myself, but without tests it can be really dangerous. @Zulko can you consider adding at least some tests from #121? Even small amount of tests better than their absence ☀️
Thanks!
The text was updated successfully, but these errors were encountered:
I was able to work around this problem by going to line 897 in VideoClip.py and in addition to checking "isinstance(img,str)" I added in "isinstance(img,str) or isinstance(img,unicode):" And then casting img as a string before sending to imread from imageio.
Hi!
Sample file:
Everything works great. But if I add
unicode_literals
:Script crashes with traceback:
If I prepend 'media/img/logo.png' with 'b':
b'media/img/logo.png'
, then stacktrace change to:Workaround to last stacktrace is to prepend 'right' and 'bottom' with 'b':
(b'right', b'bottom', )
I've found similar issue, but not exactly the same
#76
I can try to fix it myself, but without tests it can be really dangerous. @Zulko can you consider adding at least some tests from #121? Even small amount of tests better than their absence ☀️
Thanks!
The text was updated successfully, but these errors were encountered: