Moviepy: How can add my logo to right top of entire mp4 video using moviepy ?

Created on 13 Feb 2015  ·  11Comments  ·  Source: Zulko/moviepy

Hi
How can add my logo (or text) to right top of entire mp4 video using moviepy ?

Most helpful comment

Like this:

import moviepy.editor as mp

video = mp.VideoFileClip("video.mp4")

logo = (mp.ImageClip("logo.png")
          .set_duration(video.duration)
          .resize(height=50) # if you need to resize...
          .margin(right=8, top=8, opacity=0) # (optional) logo-border padding
          .set_pos(("right","top")))

final = mp.CompositeVideoClip([video, logo])
final.write_videofile("test.mp4")

Note that you can tweak the quality in write_videofile with for instance bitrate="20000k". Tell me if it works.

All 11 comments

Like this:

import moviepy.editor as mp

video = mp.VideoFileClip("video.mp4")

logo = (mp.ImageClip("logo.png")
          .set_duration(video.duration)
          .resize(height=50) # if you need to resize...
          .margin(right=8, top=8, opacity=0) # (optional) logo-border padding
          .set_pos(("right","top")))

final = mp.CompositeVideoClip([video, logo])
final.write_videofile("test.mp4")

Note that you can tweak the quality in write_videofile with for instance bitrate="20000k". Tell me if it works.

awesome!!! perfect !!!
works like a charm
thanks.

Cool. Have fun with moviepy and please report any bug you could find.

sure.

final.subclip(1000,1010).write_videofile("test.mp4") -----> from this (1000,1010) means what? can you give me share sample?

its not working? "duration (%.02f)." % self.duration)
ValueError: t_start (200.00) should be smaller than the clip's duration (1.40).

forget about the ((1000,1010)) it was just a way to cut the clip between seconds 1000 and 1010. I removed it from the example.

Hi there
the CompositeVideoClip line gives an error
MoviePy - Writing audio in testTEMP_MPY_wvf_snd.mp3

chunk: 0%| | 0/352 [00:00 chunk: 9%|▉ | 33/352 [00:00<00:00, 329.76it/s, now=None]
chunk: 12%|█▏ | 43/352 [00:02<00:27, 11.27it/s, now=None]
chunk: 26%|██▌ | 90/352 [00:03<00:16, 15.93it/s, now=None]Traceback (most recent call last):
File "E:\Intellemo Tech\adbuilder\workspace\video\putLogoOnVideoTest2.py", line 23, in
final.write_videofile("test.mp4")
File "", line 2, in write_videofile
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, a, *k)
File "", line 2, in write_videofile
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
return f(clip, new_a, *new_kw)
File "", line 2, in write_videofile
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, a, *k)
File "C:\Python\lib\site-packages\moviepyvideo\VideoClip.py", line 312, in write_videofile
self.audio.write_audiofile(audiofile, audio_fps,
File "", line 2, in write_audiofile

chunk: 29%|██▊ | 101/352 [00:19<00:15, 15.93it/s, now=None] File "C:\Python\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Python\lib\site-packages\moviepy\audio\AudioClip.py", line 205, in write_audiofile
return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
File "", line 2, in ffmpeg_audiowrite
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, a, *k)
File "C:\Python\lib\site-packages\moviepyaudio\ioffmpeg_audiowriter.py", line 166, in ffmpeg_audiowrite
for chunk in clip.iter_chunks(chunksize=buffersize,
File "C:\Python\lib\site-packages\moviepyaudio\AudioClip.py", line 84, in iter_chunks
yield self.to_soundarray(tt, nbytes=nbytes, quantize=quantize,
File "", line 2, in to_soundarray
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, a, *k)
File "C:\Python\lib\site-packages\moviepyaudio\AudioClip.py", line 126, in to_soundarray
snd_array = self.get_frame(tt)
File "", line 2, in get_frame
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(new_a, *new_kw)
File "C:\Python\lib\site-packages\moviepy\Clip.py", line 95, in get_frame
return self.make_frame(t)
File "C:\Python\lib\site-packages\moviepyaudio\AudioClip.py", line 295, in make_frame
sounds = [c.get_frame(t - c.start)np.array([part]).T
File "C:\Python\lib\site-packages\moviepyaudio\AudioClip.py", line 295, in
sounds = [c.get_frame(t - c.start)
np.array([part]).T
File "", line 2, in get_frame
File "C:\Python\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(new_a, *new_kw)
File "C:\Python\lib\site-packages\moviepy\Clip.py", line 95, in get_frame
return self.make_frame(t)
File "C:\Python\lib\site-packages\moviepyaudio\io\AudioFileClip.py", line 78, in
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Python\lib\site-packages\moviepyaudio\io\readers.py", line 184, in get_frame
self.buffer_around(fr_max)
File "C:\Python\lib\site-packages\moviepyaudio\io\readers.py", line 238, in buffer_around
array = self.read_chunk(chunksize)
File "C:\Python\lib\site-packages\moviepyaudio\io\readers.py", line 112, in read_chunk
s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'

Help!

@premj90 revert to an earlier version of moviepy

Like this:

import moviepy.editor as mp

video = mp.VideoFileClip("video.mp4")

logo = (mp.ImageClip("logo.png")
          .set_duration(video.duration)
          .resize(height=50) # if you need to resize...
          .margin(right=8, top=8, opacity=0) # (optional) logo-border padding
          .set_pos(("right","top")))

final = mp.CompositeVideoClip([video, logo])
final.write_videofile("test.mp4")

Note that you can tweak the quality in write_videofile with for instance bitrate="20000k". Tell me if it works.

How to set the set_pos custom or in any position.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cquintini picture cquintini  ·  4Comments

xjcl picture xjcl  ·  3Comments

PyB1l picture PyB1l  ·  3Comments

keikoro picture keikoro  ·  4Comments

skizzy picture skizzy  ·  3Comments