1kb不到的视频逐帧提取工具-python源码

使用方式

命令行中执行,将视频拉至窗口即可逐帧提取图像

默认生成在视频同目录下

源码中可更改每隔多少帧提取一张

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import cv2
import windnd
from tkinter import *

def video_to_imgs(sourceFile):
video_path = os.path.join("", "", sourceFile+'.MP4')
times=0
frameFrequency=30 #在此处更改每X帧截取一张
outPutDirName=''+sourceFile+'\\'
if not os.path.exists(outPutDirName):
os.makedirs(outPutDirName)
cap = cv2.VideoCapture(video_path)
while True:
times+=1
res, image = cap.read()
if not res:
break
if times%frameFrequency==0:
cv2.imencode('.jpg', image)[1].tofile(outPutDirName + str(times)+'.jpg')
print(outPutDirName + str(times)+'.jpg')
cap.release()
print('已输出至' + sourceFile + '\\')
def accept_video(files):
print(files[0][0:-4].decode('GBK'))
video_to_imgs(files[0][0:-4].decode('GBK'))
tk = Tk()
tk.wm_attributes('-topmost',1)
tk.title("视频逐帧提取丨吾爱破解")
windnd.hook_dropfiles(tk, func=accept_video)
tk.mainloop()

🔰本文标题: 1kb不到的视频逐帧提取工具-python源码

🔞本文链接: https://193.gs/py1kbshipintizhen/index.html

🌡️本文总热度