Ask Your Question
0

My saved video run in very fast for higher resolution?

asked 2020-07-01 22:44:19 -0600

ibrahim_5403 gravatar image

I saved video with 640x480 resolution and played with windows media player successfully. But when I save video with 1280x720 using opencv-python, it plays in very fast. my code sample

fourcc = cv2.VideoWriter_fourcc(*'XVID')
outVid=cv2.VideoWriter('outputMovie.mp4', fourcc, 30.0, (640, 480))

while(vid.isOpened()):
    check, frame=vid.read()
    if check:
      #print(check)
      #print(frame.shape)
      outVid.write(frame)      
      #cv2.namedWindow("Capture Video", cv2.WINDOW_NORMAL)
      cv2.imshow("Capture Video", frame)
      if cv2.waitKey(1) & 0xFF == ord('q'):
         break
    else:
         break

outVid.release()  
vid.release()
cv2.destroyAllWindows()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-07-02 01:09:57 -0600

berak gravatar image

updated 2020-07-02 06:56:11 -0600

But when I save video with 1280x720 using opencv-python, it plays in very fast.

no, that's an illusion, your video will play at 30 fps, come rain or come shine.

saving video frames is an expensive (cpu) operation, so writing larger frames will take more time (between them) on slow machines, resulting in some "time-lapse" effect.

edit flag offensive delete link more

Comments

@brahim_5403. Did you copy 1280, 720 into 6480, 480?

outVid=cv2.VideoWriter('outputMovie.mp4', fourcc, 30.0, (1280, 720))
supra56 gravatar imagesupra56 ( 2020-07-02 09:29:48 -0600 )edit

^^ supra, must have done so, else it woudn't have written any frames

berak gravatar imageberak ( 2020-07-02 09:52:16 -0600 )edit

OOOPs! My typo error not 6480. It is 640, 480

supra56 gravatar imagesupra56 ( 2020-07-02 09:58:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-01 22:44:19 -0600

Seen: 2,572 times

Last updated: Jul 02 '20