-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpu_intel.py
More file actions
42 lines (33 loc) · 1.26 KB
/
gpu_intel.py
File metadata and controls
42 lines (33 loc) · 1.26 KB
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
32
33
34
35
36
37
38
39
40
41
42
import cv2
import time
cap = cv2.VideoCapture(
"/home/mehroj/Coding/hardware-decoding/video/input.mp4",
cv2.CAP_INTEL_MFX
)
if not cap.isOpened():
print("Ошибка при открытии видео!")
exit()
video_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
video_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
video_fps = cap.get(cv2.CAP_PROP_FPS)
video_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
video_codec_num = int(cap.get(cv2.CAP_PROP_FOURCC))
video_codec = "".join([chr((video_codec_num >> 8 * i) & 0xFF) for i in range(4)])
t1 = time.time()
key_frame_count = 0
while True:
ret, frame = cap.read()
if not ret:
break
has_key_frame = cap.get(cv2.CAP_PROP_LRF_HAS_KEY_FRAME)
if has_key_frame:
key_frame_count += 1
t2 = time.time()
print(f"Размер видео ({video_width}, {video_height})")
print(f"Количество кадров: {video_frames}")
print(f"Количество ключевых кадров: {key_frame_count}")
print(f"FPS: {video_fps}")
print(f"Тип кодека видео: {video_codec}")
print(f"Длительность видео: ~{(video_frames / video_fps) / 60:.2f} минут")
duration_ms = (t2 - t1) * 1000
print(f"Занятное время: {duration_ms:.2f} Millisec")