前幾天下載了幾個視頻,但是有兩集是一個視頻的,偶爾找到了ffmpeg處理視頻的方法,它的功能非常強大。因此,分享一下,一起學習。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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進行錄制屏幕的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/qq_38641985/article/details/81532255