You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classFPSVideoStreamTrack(VideoStreamTrack):
def__init__(self, original_track):
super().__init__() # Initialize the parent classself.original_track=original_track# Store the original video trackself.start_time=time.time()
self.frame_count=0asyncdefrecv(self) ->VideoFrame:
# Receive the next frame from the original trackframe=awaitself.original_track.recv()
# Update the frame countself.frame_count+=1# Calculate FPS every 1 secondcurrent_time=time.time()
elapsed_time=current_time-self.start_timeifelapsed_time>1.0:
fps=self.frame_count/elapsed_timeprint(f"FPS: {fps:.2f}")
# Reset frame count and timerself.frame_count=0self.start_time=current_timereturnframe
How to check fps from stream using only python? Is there any examples or somth?
The text was updated successfully, but these errors were encountered: