使用Python+moviepy在视频画面上绘制边框

一、 使用VideoFileClip对象的的fx函数设置vfx.margin,在视频画面上绘制边框

python 复制代码
from moviepy.editor import * 

mv=VideoFileClip('/home/Download/leaves.mp4') 

mv2=mv.fx(vfx.margin,mar=3,color=(0,0,255),opacity=0.5) # 绘制边框

# mar=3 :边框宽度3像素,生效优先级高于:left=3,right=3,top=3,bottom=3

# color=(0,0,255) : 边框颜色是蓝色

# opacity=0.5 : 边框透明度0.5(半透明)

mv2.write_videofile('/home/Download/margin.mp4')

二、 使用VideoFileClip对象的的fx函数设置vfx.margin,在视频画面上绘制边框,边框四条边宽度单独设置

python 复制代码
from moviepy.editor import * 

mv=VideoFileClip('/home/Download/leaves.mp4') 

mv2=mv.fx(vfx.margin,left=3,right=4,top=5,bottom=6,color=(0,0,255),opacity=0.5)  # 绘制边框

# left=3 :左边框宽度3像素

# right=4 :右边框宽度4像素

# top=5 :上边框宽度5像素

# bottom=6 :下边框宽度6像素

# color=(0,0,255) : 边框颜色是蓝色

# opacity=0.5 : 边框透明度0.5(半透明)

mv2.write_videofile('/home/Download/margin.mp4')
相关推荐
花酒锄作田12 小时前
Pydantic校验配置文件
python
hboot13 小时前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi1 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi1 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽1 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户8358086187911 天前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L2 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅2 天前
海天线算法的前世今生
python·计算机视觉
韩师傅2 天前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L2 天前
LangGraph的MessageState and HumanMessage
python