fix bad commit I just made

This commit is contained in:
Yonokid
2025-05-02 00:22:05 -04:00
parent 2fda744f9b
commit 08394cf97a
2 changed files with 13 additions and 8 deletions

View File

@@ -7,7 +7,9 @@ from threading import Lock, Thread
import pyray as ray import pyray as ray
from numpy import ( from numpy import (
abs, abs as np_abs,
)
from numpy import (
column_stack, column_stack,
float32, float32,
frombuffer, frombuffer,
@@ -17,6 +19,9 @@ from numpy import (
uint8, uint8,
zeros, zeros,
) )
from numpy import (
max as np_max,
)
os.environ["SD_ENABLE_ASIO"] = "1" os.environ["SD_ENABLE_ASIO"] = "1"
import sounddevice as sd import sounddevice as sd
@@ -550,7 +555,7 @@ class ASIOEngine:
output *= self.master_volume output *= self.master_volume
# Apply simple limiter to prevent clipping # Apply simple limiter to prevent clipping
max_val = max(abs(output)) max_val = np_max(np_abs(output))
if max_val > 1.0: if max_val > 1.0:
output = output / max_val output = output / max_val

View File

@@ -1,5 +1,5 @@
import cv2
import pyray as ray import pyray as ray
from cv2 import CAP_PROP_FPS, COLOR_BGR2RGB, VideoCapture, cvtColor
from libs.audio import audio from libs.audio import audio
from libs.utils import get_current_ms from libs.utils import get_current_ms
@@ -13,8 +13,8 @@ class VideoPlayer:
self.last_frame = self.current_frame self.last_frame = self.current_frame
self.frame_index = 0 self.frame_index = 0
self.frames = [] self.frames = []
self.cap = cv2.VideoCapture(self.video_path) self.cap = VideoCapture(self.video_path)
self.fps = self.cap.get(cv2.CAP_PROP_FPS) self.fps = self.cap.get(CAP_PROP_FPS)
self.is_finished_list = [False, False, False] # Added third flag for frame conversion self.is_finished_list = [False, False, False] # Added third flag for frame conversion
self.all_frames_converted = False self.all_frames_converted = False
audio_path = path[:-4] + '.ogg' audio_path = path[:-4] + '.ogg'
@@ -32,7 +32,7 @@ class VideoPlayer:
success, frame = self.cap.read() success, frame = self.cap.read()
while success: while success:
timestamp = (frame_count / self.fps * 1000) timestamp = (frame_count / self.fps * 1000)
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) frame_rgb = cvtColor(frame, COLOR_BGR2RGB)
new_frame = ray.Image(frame_rgb.tobytes(), frame_rgb.shape[1], frame_rgb.shape[0], 1, ray.PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8) new_frame = ray.Image(frame_rgb.tobytes(), frame_rgb.shape[1], frame_rgb.shape[0], 1, ray.PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8)
self.frames.append((timestamp, new_frame)) self.frames.append((timestamp, new_frame))
success, frame = self.cap.read() success, frame = self.cap.read()
@@ -50,7 +50,7 @@ class VideoPlayer:
return return
if not self.cap.isOpened(): if not self.cap.isOpened():
self.cap = cv2.VideoCapture(self.video_path) self.cap = VideoCapture(self.video_path)
if not self.cap.isOpened(): if not self.cap.isOpened():
raise ValueError("Error: Could not open video file.") raise ValueError("Error: Could not open video file.")
@@ -58,7 +58,7 @@ class VideoPlayer:
success, frame = self.cap.read() success, frame = self.cap.read()
if success: if success:
timestamp = (len(self.frames) / self.fps * 1000) timestamp = (len(self.frames) / self.fps * 1000)
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) frame_rgb = cvtColor(frame, COLOR_BGR2RGB)
new_frame = ray.Image(frame_rgb.tobytes(), frame_rgb.shape[1], frame_rgb.shape[0], 1, ray.PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8) new_frame = ray.Image(frame_rgb.tobytes(), frame_rgb.shape[1], frame_rgb.shape[0], 1, ray.PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8)
self.frames.append((timestamp, new_frame)) self.frames.append((timestamp, new_frame))
else: else: