[Python] How to set time interval to get frames from input video?

Discussão em 'Python' iniciado por Stack, Setembro 6, 2025.

  1. Stack

    Stack Membro Participativo

    I m trying to get frames from input video for particular time interval.so suggest me any solution that would be helpful for me.Tell me how to set time limit in the following code.

    import cv2

    vidcap = cv2.VideoCapture('baahubali2.mp4')
    vidcap.set(cv2.CAP_PROP_POS_MSEC,1000)

    success, image = vidcap.read()
    count = 0
    success = True

    while success:
    success, image = vidcap.read()
    print('Read a new frame: ', success)
    cv2.imwrite("/home/kapil/Documents/major/image/frame%d.jpg" % count, image)
    count += 1

    Continue reading...

Compartilhe esta Página