python sk-video reading mp4 with variable frame rate - missing frames

127 Views Asked by At

I have some video files captured via Windows Camera app. The files are saved in mp4 format with variable frame rate.

When I read a video file using

vrf_video = skvideo.io.vread(video_path)
frame_sk = vrf_video[index]

I see that the last frames of the video are missing when compared to reading the video using

vrf_vid_cv2 = cv2.VideoCapture(in_path)
ret, frame_cv2 = vrf_vid_cv2.read()

So I wonder why, where did the last frames go when reading them in the sk-video package?

Reproducible code:

import cv2
import skvideo
skvideo.setFFmpegPath(ffmpeg_path)
import skvideo.io
vrf_vid = skvideo.io.vread(video_path)
idx = 0
while True:
    vrf_vid_frame = vrf_vid[idx]
    cv2.imshow('vrf frame', vrf_vid_frame)
    key = cv2.waitKey(10) & 0xFF
    if key == 27: # esc key
        break
    elif key == 46:  # ">"
        idx = idx + 1
    elif key == 44:  # "<"
        idx = max(0, idx-1)

The last frame of the video is not the last frame in the list. Works with every video shot with Windows Camera app.

0

There are 0 best solutions below