Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can add my logo to right top of entire mp4 video using moviepy ? #127

Closed
ebin123456 opened this issue Feb 13, 2015 · 11 comments
Closed

Comments

@ebin123456
Copy link

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

@Zulko
Copy link
Owner

Zulko commented Feb 13, 2015

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.

@ebin123456
Copy link
Author

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

@Zulko
Copy link
Owner

Zulko commented Feb 13, 2015

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

@Zulko Zulko closed this as completed Feb 13, 2015
@ebin123456
Copy link
Author

sure.

@selvakarna
Copy link

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

@selvakarna
Copy link

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

@Zulko
Copy link
Owner

Zulko commented Jun 17, 2019

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.

@premj90
Copy link

premj90 commented Jan 28, 2020

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

chunk: 0%| | 0/352 [00:00<?, ?it/s, now=None]
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 "<C:\Python\lib\site-packages\decorator.py:decorator-gen-51>", 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 "<C:\Python\lib\site-packages\decorator.py:decorator-gen-50>", 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 "<C:\Python\lib\site-packages\decorator.py:decorator-gen-49>", 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\moviepy\video\VideoClip.py", line 312, in write_videofile
self.audio.write_audiofile(audiofile, audio_fps,
File "<C:\Python\lib\site-packages\decorator.py:decorator-gen-73>", 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 "<C:\Python\lib\site-packages\decorator.py:decorator-gen-70>", 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\moviepy\audio\io\ffmpeg_audiowriter.py", line 166, in ffmpeg_audiowrite
for chunk in clip.iter_chunks(chunksize=buffersize,
File "C:\Python\lib\site-packages\moviepy\audio\AudioClip.py", line 84, in iter_chunks
yield self.to_soundarray(tt, nbytes=nbytes, quantize=quantize,
File "<C:\Python\lib\site-packages\decorator.py:decorator-gen-72>", 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\moviepy\audio\AudioClip.py", line 126, in to_soundarray
snd_array = self.get_frame(tt)
File "<C:\Python\lib\site-packages\decorator.py:decorator-gen-10>", 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\moviepy\audio\AudioClip.py", line 295, in make_frame
sounds = [c.get_frame(t - c.start)*np.array([part]).T
File "C:\Python\lib\site-packages\moviepy\audio\AudioClip.py", line 295, in
sounds = [c.get_frame(t - c.start)*np.array([part]).T
File "<C:\Python\lib\site-packages\decorator.py:decorator-gen-10>", 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\moviepy\audio\io\AudioFileClip.py", line 78, in
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Python\lib\site-packages\moviepy\audio\io\readers.py", line 184, in get_frame
self.buffer_around(fr_max)
File "C:\Python\lib\site-packages\moviepy\audio\io\readers.py", line 238, in buffer_around
array = self.read_chunk(chunksize)
File "C:\Python\lib\site-packages\moviepy\audio\io\readers.py", line 112, in read_chunk
s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'

Help!

@codedocta
Copy link

@premj90 revert to an earlier version of moviepy

@mgaitan mgaitan mentioned this issue Jul 21, 2020
@ssadev
Copy link

ssadev commented Nov 13, 2020

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.

@tburrows13
Copy link
Collaborator

https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html?#moviepy.video.VideoClip.VideoClip.set_position

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants