美丽心灵公益论坛

查看: 1698|回复: 0

MoviePy加水印

[复制链接]
累计签到:57 天
连续签到:1 天

981

主题

461

回帖

8037

积分

版主

Rank: 7Rank: 7Rank: 7

积分
8037
发表于 2022-4-9 00:22:22| 字数 884 来自手机 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
https://shenli.dev/2015/10/18/ho ... eo-with-python.html
from moviepy.editor import *

my_clip = VideoFileClip("../../videos/moi_ukulele.MOV", audio=True)  #  The video file with audio enabled

w,h = my_clip.size  # size of the clip

# A CLIP WITH A TEXT AND A BLACK SEMI-OPAQUE BACKGROUND

txt = TextClip("THE WATERMARK TEXT", font='Amiri-regular',
                       color='white',fontsize=24)

txt_col = txt.on_color(size=(my_clip.w + txt.w,txt.h-10),
                  color=(0,0,0), pos=(6,'center'), col_opacity=0.6)

# This example demonstrates a moving text effect where the position is a function of time(t, in seconds).
# You can fix the position of the text manually, of course. Remember, you can use strings,
# like 'top', 'left' to specify the position
txt_mov = txt_col.set_pos( lambda t: (max(w/30,int(w-0.5*w*t)),
                                  max(5*h/6,int(100*t))) )

# Write the file to disk
final = CompositeVideoClip([my_clip,txt_mov])
final.duration = my_clip.duration
final.write_videofile("OUT.mp4",fps=24,codec='libx264')
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|免责及版权声明|关于|美丽心灵公益论坛

GMT+8, 2025-10-31 21:52 , Processed in 0.102641 second(s), 26 queries .

Powered by Discuz! X3.4

!copyright!

快速回复 返回顶部 返回列表