"stuck" frames being skipped when using VideoWriter?
I have a video that has "stuck" frames that remain on screen without changing due to lag. I read and write this video wihtout making any changes to it using opencv
cap = cv2.VideoCapture('input.mp4')
size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
fps = cap.get(cv2.CAP_PROP_FPS)
outputVideo = 'output.mp4'
out = cv2.VideoWriter(outputVideo,fourcc, fps, (size))
while (cap.isOpened()):
ret, frame = cap.read()
if ret == True:
out.write(frame)
else:
break
out.release()
the video that I get in return has almost the same length as the original (it has 2 less seconds) but lo and behold the stuck frames aren't there anymore. At the start, the new video is ahead of the original, but by the end it's lagging behind. My best guess is that it has to do with the video compression/encoder that I use. I would like make the video so that each frame is presented at the same time as in the original. Any help is appreciated