-
Notifications
You must be signed in to change notification settings - Fork 31
Description
VideoCaptureStreamRT consistently reports double the actual fps. For an 8 fps stream, it reports 16 fps.
As a baseline, here is the ffprobe output for the stream under test:
Metadata:
title : Session streamed by "preview"
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 2304x1296, 8 fps, 16 tbr, 90k tbn
Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
8 fps is correct.
For the same stream, VideoCaptureStreamRT says the vid.fps is 16 fps.
It comes to that conclusion from reading the r_frame_rate of the vinfo dict:
vinfo: {'index': 0, 'codec_name': 'h264', 'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'profile': 'High', 'codec_type': 'video', 'codec_tag_string': '[0][0][0][0]', 'codec_tag': '0x0000', 'width': 2304, 'height': 1296, 'coded_width': 2304, 'coded_height': 1296, 'closed_captions': 0, 'film_grain': 0, 'has_b_frames': 0, 'pix_fmt': 'yuv420p', 'level': 51, 'chroma_location': 'left', 'field_order': 'progressive', 'refs': 1, 'is_avc': 'false', 'nal_length_size': '0', 'r_frame_rate': '16/1', 'avg_frame_rate': '0/0', 'time_base': '1/90000', 'bits_per_raw_sample': '8', 'extradata_size': 24, 'disposition': {'default': 0, 'dub': 0, 'original': 0, 'comment': 0, 'lyrics': 0, 'karaoke': 0, 'forced': 0, 'hearing_impaired': 0, 'visual_impaired': 0, 'clean_effects': 0, 'attached_pic': 0, 'timed_thumbnails': 0, 'captions': 0, 'descriptions': 0, 'metadata': 0, 'dependent': 0, 'still_image': 0}}
To produce the proper 8fps, I changed the following line in stream_info.py
def get_info(stream_url, timeout=None, duration_ms: int = 100):
To this line:
def get_info(stream_url, timeout=None, duration_ms: int = 1000):
Now the vinfo dict reads as follows:
vinfo: {'index': 0, 'codec_name': 'h264', 'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'profile': 'High', 'codec_type': 'video', 'codec_tag_string': '[0][0][0][0]', 'codec_tag': '0x0000', 'width': 2304, 'height': 1296, 'coded_width': 2304, 'coded_height': 1296, 'closed_captions': 0, 'film_grain': 0, 'has_b_frames': 0, 'pix_fmt': 'yuv420p', 'level': 51, 'chroma_location': 'left', 'field_order': 'progressive', 'refs': 1, 'is_avc': 'false', 'nal_length_size': '0', r_frame_rate': '16/1', 'avg_frame_rate': '8/1', 'time_base': '1/90000', 'start_pts': 9808, 'start_time': '0.108978', 'bits_per_raw_sample': '8', 'extradata_size': 24, 'disposition': {'default': 0, 'dub': 0, 'original': 0, 'comment': 0, 'lyrics': 0, 'karaoke': 0, 'forced': 0, 'hearing_impaired': 0, 'visual_impaired': 0, 'clean_effects': 0, 'attached_pic': 0, 'timed_thumbnails': 0, 'captions': 0, 'descriptions': 0, 'metadata': 0, 'dependent': 0, 'still_image': 0}}
If you now take avg_frame_rate instead of r_frame_rate, you get the correct 8 fps frame rate of the stream.