Missing Frames During Video Processing

#1
by dfg543 - opened

Some frames are missing in the video, for example, in -1CahRD6lJ0.avi. The video is declared to have 4127 frames, but only 3957 frames can be successfully read. Below is the code:

import cv2

# Load video
video_path = "/mnt/windows-share/scottgeng00/realtalk/videos/-1CahRD6lJ0.avi"
video = cv2.VideoCapture(video_path)

# Get total number of frames
total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
print(f"Declared total frames: {total_frames}")

# Actual number of frames read
read_frames = 0
while True:
    ret, frame = video.read()
    if not ret:  # If reading fails, end the loop
        break
    read_frames += 1

video.release()
print(f"Successfully read frames: {read_frames}")

# Compare the two numbers
if read_frames != total_frames:
    print(f"Frame mismatch detected: {total_frames - read_frames} frames missing.")
else:
    print("All frames were successfully decoded.")

Output:

(data) [root@Arc-AI /mnt/241hdd/wzr/realtalk]$ python check.py
Declared total frames: 4127
Successfully read frames: 3957
Frame mismatch detected: 170 frames missing.

This issue is also evident when using ffmpeg. I randomly checked several videos, and they all show the same problem.

Your need to confirm your account before you can post a new comment.

Sign up or log in to comment