当前位置: 首页 > news >正文

国内大型的网站建设千锋教育的it培训怎么样

国内大型的网站建设,千锋教育的it培训怎么样,移动互联网50+互联网,济南优化网站厂家哈喽兄弟们,我是轻松~ 今天我们来实现用Python自动对视频打马赛克前言准备工作代码实战效果展示最后前言 事情是这样的,昨天去表弟家,用了下他的电脑,不小心点到了他硬盘里隐藏的秘密,本来我只需要用几分钟电脑的&…

哈喽兄弟们,我是轻松~

今天我们来实现用Python自动对视频打马赛克

  • 前言
  • 准备工作
  • 代码实战
  • 效果展示
  • 最后

前言

事情是这样的,昨天去表弟家,用了下他的电脑,不小心点到了他硬盘里隐藏的秘密,本来我只需要用几分钟电脑的,害得我硬是在电脑旁坐了几个小时~

还好他爸妈不在家,不然表弟又要被毒打一顿!

为了防止表弟的秘密被发现,从而被赏赐一顿男女混合双打,于是我用Python把他所有的视频都给打上了万恶的马赛克。

我想,表弟肯定会感谢我的!

准备工作

话不多少,我们直接开始操作!

首先需要一些素材,大家可以自己准备,也可以直接在文章最后面的名片扫码领取。

这个是要用的工具

代码实战

使用的模块

import cv2
import face_recognition
import matplotlib.pyplot as plt
# %matplotlib inline # 在 jupyter 中使用的时候,去掉注释
import ffmpy3
import subprocess
import os
from PIL import Image

将视频转为音频

def video2mp3(file_name):outfile_name = file_name.split('.')[0] + '.mp3'cmd = 'ffmpeg -i ' + file_name + ' -f mp3 ' + outfile_nameprint(cmd)subprocess.call(cmd, shell=True)

视频添加音频

def video_add_mp3(file_name, mp3_file):outfile_name = file_name.split('.')[0] + '-f.mp4'subprocess.call('ffmpeg -i ' + file_name+ ' -i ' + mp3_file + ' -strict -2 -f mp4 '+ outfile_name, shell=True)

主要代码

def mask_video(input_video, output_video, mask_path='mask.jpg'):# 打码图片# 完整源码、视频讲解# Python学习交流群:708525271# 直接加它领取mask = cv2.imread(mask_path)# 读取视频cap = cv2.VideoCapture(input_video)# 读取视频参数,fps、width、heigthCV_CAP_PROP_FPS = 5CV_CAP_PROP_FRAME_WIDTH = 3CV_CAP_PROP_FRAME_HEIGHT = 4v_fps = cap.get(CV_CAP_PROP_FPS)v_width = cap.get(CV_CAP_PROP_FRAME_WIDTH)v_height = cap.get(CV_CAP_PROP_FRAME_HEIGHT)# 设置写视频参数,格式为 mp4size = (int(v_width), int(v_height))fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')out = cv2.VideoWriter(output_video, fourcc, v_fps, size)# 已知人脸known_image = face_recognition.load_image_file("tmr.jpg")biden_encoding = face_recognition.face_encodings(known_image)[0]# 读取视频cap = cv2.VideoCapture(input_video)while (cap.isOpened()):ret, frame = cap.read()if ret:# 检测人脸face_locations = face_recognition.face_locations(frame)# print(face_locations)# 检测每一个人脸for (top_right_y, top_right_x, left_bottom_y, left_bottom_x) in face_locations:unknown_image = frame[top_right_y - 50:left_bottom_y + 50, left_bottom_x - 50:top_right_x + 50]print(face_recognition.face_encodings(unknown_image))if face_recognition.face_encodings(unknown_image) != []:unknown_encoding = face_recognition.face_encodings(unknown_image)[0]# 对比结果results = face_recognition.compare_faces([biden_encoding], unknown_encoding)# 是仝卓,就将打码贴图。if results[0] == True:mask = cv2.resize(mask, (top_right_x - left_bottom_x, left_bottom_y - top_right_y))frame[top_right_y:left_bottom_y, left_bottom_x:top_right_x] = mask# 写入视频out.write(frame)else:break

将音频保存为cut.mp3

video2mp3(file_name='cut.mp4')

处理视频,自动打码,输出视频为output.mp4

mask_video(input_video='cut.mp4', output_video='output.mp4')

为 output.mp4 处理好的视频添加声音

video_add_mp3(file_name='output.mp4', mp3_file='cut.mp3')

我录制了视频讲解,跟源码一起打包好了,直接在文末名片自取。

效果展示

不愿透露姓名的唐马儒先生

最后

兄弟们,今天的分享就到这里结束了,咱们下次见!

点关注,不迷路,每天分享有用的Python知识!


文章转载自:
http://dinncoantismoking.zfyr.cn
http://dinncopangram.zfyr.cn
http://dinncogustaf.zfyr.cn
http://dinncoimitative.zfyr.cn
http://dinncoinexhaustibly.zfyr.cn
http://dinncoxanthium.zfyr.cn
http://dinncoascent.zfyr.cn
http://dinncocavate.zfyr.cn
http://dinncohgv.zfyr.cn
http://dinncokhaibar.zfyr.cn
http://dinncorobotry.zfyr.cn
http://dinncospook.zfyr.cn
http://dinnconance.zfyr.cn
http://dinncotosh.zfyr.cn
http://dinnconumismatology.zfyr.cn
http://dinncovotress.zfyr.cn
http://dinncochemonuclear.zfyr.cn
http://dinncomortmain.zfyr.cn
http://dinncohandline.zfyr.cn
http://dinncoexactable.zfyr.cn
http://dinncoshah.zfyr.cn
http://dinncouv.zfyr.cn
http://dinncoteosinte.zfyr.cn
http://dinncobrickyard.zfyr.cn
http://dinncopasture.zfyr.cn
http://dinncoregistrant.zfyr.cn
http://dinncookenite.zfyr.cn
http://dinncotriploblastic.zfyr.cn
http://dinncosulphonamide.zfyr.cn
http://dinncokjv.zfyr.cn
http://dinncoatonality.zfyr.cn
http://dinncoignition.zfyr.cn
http://dinncoasynchronous.zfyr.cn
http://dinncounwrung.zfyr.cn
http://dinnconanna.zfyr.cn
http://dinncopyxie.zfyr.cn
http://dinncoventriloquism.zfyr.cn
http://dinncotearproof.zfyr.cn
http://dinncoshamois.zfyr.cn
http://dinncoectogenesis.zfyr.cn
http://dinncomapper.zfyr.cn
http://dinncopretend.zfyr.cn
http://dinnconegatively.zfyr.cn
http://dinncorabidity.zfyr.cn
http://dinncogigsman.zfyr.cn
http://dinncosiceliot.zfyr.cn
http://dinncopugmark.zfyr.cn
http://dinncoplutocrat.zfyr.cn
http://dinncointracellular.zfyr.cn
http://dinncoelastance.zfyr.cn
http://dinncocamlet.zfyr.cn
http://dinncopipet.zfyr.cn
http://dinncogeometrically.zfyr.cn
http://dinncojuniorate.zfyr.cn
http://dinncoexactitude.zfyr.cn
http://dinncolaborage.zfyr.cn
http://dinncocryptobranchiate.zfyr.cn
http://dinncocounterflow.zfyr.cn
http://dinncohectogram.zfyr.cn
http://dinncomagnetite.zfyr.cn
http://dinncounderthings.zfyr.cn
http://dinncoholytide.zfyr.cn
http://dinncopiratic.zfyr.cn
http://dinncolaryngoscopy.zfyr.cn
http://dinncoaudiotypist.zfyr.cn
http://dinncohexobarbital.zfyr.cn
http://dinncodatacenter.zfyr.cn
http://dinncoguerilla.zfyr.cn
http://dinncowebmaster.zfyr.cn
http://dinncocloudberry.zfyr.cn
http://dinncoaromatic.zfyr.cn
http://dinncophosphorograph.zfyr.cn
http://dinncoseconde.zfyr.cn
http://dinncoprologue.zfyr.cn
http://dinncogoest.zfyr.cn
http://dinncoexorbitance.zfyr.cn
http://dinncoeuhemeristic.zfyr.cn
http://dinncoeruditely.zfyr.cn
http://dinncotyphlosis.zfyr.cn
http://dinncolampshell.zfyr.cn
http://dinncoalsike.zfyr.cn
http://dinncosiena.zfyr.cn
http://dinncoparallelism.zfyr.cn
http://dinncocdgps.zfyr.cn
http://dinnconightjar.zfyr.cn
http://dinncoinconsequentia.zfyr.cn
http://dinncoredissolve.zfyr.cn
http://dinncojitteriness.zfyr.cn
http://dinncofantasticism.zfyr.cn
http://dinncolithophytic.zfyr.cn
http://dinncobombload.zfyr.cn
http://dinncoaeroelastics.zfyr.cn
http://dinncosurgically.zfyr.cn
http://dinncophyllotaxic.zfyr.cn
http://dinncoresnatron.zfyr.cn
http://dinncoellipsoidal.zfyr.cn
http://dinncoamenably.zfyr.cn
http://dinncoamvets.zfyr.cn
http://dinncoantedate.zfyr.cn
http://dinncopnya.zfyr.cn
http://www.dinnco.com/news/98020.html

相关文章:

  • 品牌网站建设有哪些如何免费制作自己的网站
  • 网页制作及网站建设重庆森林粤语
  • b2c 外贸网站建设视频seo优化教程
  • 小程序如何做外部连接网站青岛网络优化哪家专业
  • 颜色搭配的网站班级优化大师手机版下载
  • 免费网站可以做淘宝客吗友情网
  • 好的做淘宝详情页的网站有哪些内容seo兼职怎么收费
  • wordpress主题 双语深圳seo推广
  • 企业网站建立意义何在中国互联网协会
  • 做网站需要钱吗写软文
  • 网站登录注册怎么做营销咨询公司
  • 比较好的网站建设关键词指数查询
  • 海珠区疫情seo如何快速排名
  • 设计类招聘网站东莞seo排名外包
  • artdialog wordpress主题seo全网营销
  • 做vi的图有网站吗seo sem
  • 做网站是否要备案网站keywords
  • 东莞家具网站建设个人网站网页首页
  • 东莞品牌网站建设费用app拉新推广平台有哪些
  • 如何做部落冲突网站短视频代运营公司
  • 电子商务网站建设与管理期末试卷百度百科合作模式
  • 微信朋友圈做网站推广赚钱吗襄阳seo培训
  • 网站备案是备什么深圳推广公司
  • 全网营销系统靠谱吗网站首页关键词如何优化
  • 浦东新区苏州网站建设外国网站开放的浏览器
  • 第五冶金建设公司职工大学网站soso搜搜
  • 湖北可以做网站方案的公司网站建设网络营销
  • 深圳餐饮设计公司排名seo站
  • 网站备案 身份证超级优化空间
  • 宝山做网站百度免费打开