1.安装FFmpeg
http://ffmpeg.org/download.html
嫌麻烦我这提供网盘
链接:https://pan.baidu.com/s/1C-8FN9rhvrg4TzxrMHTxlQ
提取码:picg
bin目录中的运行程序自己配置一下环境变量
2.安装python模块
pip3 install ffmpy
3.代码以及注释(京东为例子)
import cv2
import os
import requests
url = \'https://vod.300hu.com/4c1f7a6atransbjngwcloud1oss/0b9b4ed1210322894260592641/v.f30.mp4?dockingId=ff7cfcee-bd65-4da3-b77b-ec64339f8786&storageSource=3\'
with open(\'1.mp4\', \'wb\') as fw:
fw.write(requests.get(url).content) #为了把视频下载到本地
video_path = "1.mp4"
cap = cv2.VideoCapture(video_path) #opencv读取视频对象
frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) #获取视频宽
# 获取视频高度
#frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
print(frame_width)
delogo_x = frame_width - 310 #京东水印宽大改300不过为了让他长度不超过边界这边故意多剪了10
cmd = f\'ffmpeg -i {video_path} -filter_complex "delogo=x={delogo_x}:y=1:w=300:h=70:show=0" 2.mp4\'
# -i 视频路径
#delogo去除视频某处的logo。其实实现原理就是将给出区域进行高斯模糊处理。始x于y,wh为覆盖水印的长宽,band是模糊强度
#show=1 便于调试他会出现一个绿色的框,去除水印的时候要把show改为0
# 补充点:-vf:video_filter 滤镜 ;-filger_complex混合滤镜
os.system(cmd)