python利用ffmpeg进行录制屏幕的方法

yipeiwu_com7年前Python基础

前几天下载了几个视频,但是有两集是一个视频的,偶尔找到了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通过urllib2爬网页上种子下载示例

通过urllib2、re模块抓种子 思路 1.用程序登录论坛(如果需要登录才能访问的版块) 2.访问指定版块 3.遍历帖子(先取指定页,再遍历页面所有帖子的url) 4.循环访问所有帖子...

Pyhton中防止SQL注入的方法

复制代码 代码如下: c=db.cursor() max_price=5 c.execute("""SELECT spam, eggs, sausage FROM breakfast &...

Python3.2中Print函数用法实例详解

本文实例讲述了Python3.2中Print函数用法。分享给大家供大家参考。具体分析如下: 1. 输出字符串 >>> strHello = 'Hello World...

Python实现扫描局域网活动ip(扫描在线电脑)

内网的主机都是自动分配ip地址,有时候需要查看下有那些ip在使用,就写了个简单的脚本。 linux和windows下都可以用,用多线程来ping1-255所有的地址,效率不高,2分钟左右...

Python黑帽编程 3.4 跨越VLAN详解

Python黑帽编程 3.4 跨越VLAN详解

VLAN(Virtual Local Area Network),是基于以太网交互技术构建的虚拟网络,既可以将同一物理网络划分成多个VALN,也可以跨越物理网络障碍,将不同子网中的用户划...