Skip to content

VideoCapture.get(cv::CAP_PROP_FPS) is wrong for some special video #21006

@wangwei1237

Description

@wangwei1237
System information (version)
  • OpenCV => 4.5.0
  • Operating System / Platform => MacOS 12.0.1
  • Compiler => clang 12.0.5
Detailed description

The FPS get from VideoCapture.get(cv::CAP_PROP_FPS) is wrong.

The coding as following:

cv::VideoCapture cap;
cap.open(std::string(argv[1]));

if (!cap.isOpened()) {
    std::cout << "Cannot open the video file" << std::endl;
    return -1;
}

const double FPS = cap.get(cv::CAP_PROP_FPS);
std::cout << "FPS: " << FPS << std::endl;

The result for this program as following:

$ ./a.out test.ts
FPS: 2000

But the ffprobe result as following:

Input #0, mpegts, from 'test.ts':
  Duration: 00:00:05.43, start: 582.336233, bitrate: 2702 kb/s
  Program 1
    Metadata:
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 720x1280 [SAR 1:1 DAR 9:16], 30 tbr, 90k tbn, 2k tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 128 kb/s

[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=0/2
codec_tag_string=[27][0][0][0]
codec_tag=0x001b
width=720
height=1280
coded_width=720
coded_height=1280
closed_captions=0
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=9:16
pix_fmt=yuv420p
level=31
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
is_avc=false
nal_length_size=0
id=0x100
r_frame_rate=30/1
avg_frame_rate=0/0
time_base=1/90000
start_pts=52418880
start_time=582.432000
duration_ts=480000
duration=5.333333
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
[/STREAM]

Thus, the fps for this ts video file is 30, but VideoCapture.get(cv::CAP_PROP_FPS) return 2000.

Steps to reproduce
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions