Add capability for video recording
Requirements:
- video recording of tests
- set record on failure flag
- set separately to screenshots
Example python code currently used:
import os
import threading
import time
import numpy as np
from cv2 import cv2
from mss import mss
from definitions import VIDEO_RECORDINGS_DIR
class VideoRecorder:
def __init__(self, name):
self.name: str = name
self.video_recording_dir = VIDEO_RECORDINGS_DIR
def get_screen_recording(self):
t = threading.current_thread()
with mss() as sct:
mon = sct.monitors[0]
fourcc = cv2.VideoWriter_fourcc(*"vp09")
desired_fps = 5.0
out = cv2.VideoWriter(
os.path.join(self.video_recording_dir, self.name),
fourcc,
desired_fps,
(mon["width"], mon["height"]),
)
last_time = 0
while getattr(t, "do_run", True):
img = sct.grab(mon)
if time.time() - last_time > 1.0 / desired_fps:
last_time = time.time()
dest_rgb = cv2.cvtColor(np.array(img), cv2.COLOR_BGRA2BGR)
out.write(dest_rgb)
out.release()
cv2.destroyAllWindows()