前几天下载了几个视频,但是有两集是一个视频的,偶尔找到了ffmpeg处理视频的方法,它的功能非常强大。因此,分享一下,一起学习。
import subprocess,sys,os import re class CutSplicingVdeio(object): def __init__(self): pass #dercription CutSplicingVdeio this class function def instructions(self): dercription="vdeio and image transform,vdeio other opreation" return dercription def transcribeScreen(self,filePath): filePath=filePath.decode('utf-8') cmd=ffmpegPath + " -f gdigrab -framerate 60 -offset_x 0 -offset_y 0 -video_size 1366x768 -i desktop " + filePath cmd=cmd.encode(sys.getfilesystemencoding()) if "?" in cmd: cmd=cmd.replace("?","") print cmd subprocess.call(cmd , shell=True) vp=CutSplicingVdeio() vp.transcribeScreen(r"C:\Users\Administrator\Desktop\transcribe.avi") #according to give a video filepath (transcribe Screen)
首先,写了一个api,里面的的一个录制屏幕的功能,其他的暂时没写,以后再分享。
vp.transcribeScreen传递路径后执行transcribeScreen,为让中文显示正常转换一下编码格式,
之后执行cmd命令即可。
win7系统执行后报错,不知原因,排产原因是在路径里多出一个?,去除之后,完美运行。
也可以直接cmd运行 D:\LenovoC\ffmpeg\bin\ffmpeg.exe -f gdigrab -framerate 60 -offset_x 0 -offset_y 0 -video_size 1366x768 -i desktop C:\Users\Administrator\Desktop\transcribe.avi。
好了今天就到这里。
以上这篇python利用ffmpeg进行录制屏幕的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
- Python实现屏幕录制功能的代码
- 使用Python来做一个屏幕录制工具的操作代码
- Python+opencv+pyaudio实现带声音屏幕录制
- python 实现屏幕录制示例
- 用Python监控你的朋友都在浏览哪些网站?
- 用python实现监控视频人数统计
- Python实现用手机监控远程控制电脑的方法
- python实现的web监控系统
- python 自动监控最新邮件并读取的操作
- 只用20行Python代码实现屏幕录制功能
转载请注明出处:http://www.fdzxgo.com/article/20230526/224828.html