from daily import CallClient, VideoFrame
import numpy as np
import cv2
class VideoDisplay:
def __init__(self, window_name: str):
self.window_name = window_name
cv2.namedWindow(window_name)
def video_callback(self, participant_id: str, video_frame: VideoFrame, video_source: str):
# Convert to numpy array
frame = np.frombuffer(video_frame.buffer, dtype=np.uint8)
frame = frame.reshape((video_frame.height, video_frame.width, 4))
# Convert RGBA to BGR for display
bgr_frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
# Add timestamp overlay
timestamp_ms = video_frame.timestamp_us // 1000
cv2.putText(
bgr_frame,
f"Timestamp: {timestamp_ms}ms",
(10, 30),
cv2.FONT_HERSHEY_SIMPLEX,
1,
(0, 255, 0),
2
)
# Display frame
cv2.imshow(self.window_name, bgr_frame)
cv2.waitKey(1)
def close(self):
cv2.destroyWindow(self.window_name)
# Usage
display = VideoDisplay("Participant Video")
client = CallClient()
client.set_video_renderer(
participant_id="participant-id",
callback=display.video_callback,
color_format="RGBA"
)
# Later: cleanup
display.close()