0

I want to show the seconds while the video is playing, but the time isnt the same as the original video:

video = cv2.VideoCapture("edited.mp4");
fps = video.get(cv2.CAP_PROP_FPS);
frame_count = video.get(cv2.CAP_PROP_FRAME_COUNT);
duration = int(frame_count / fps);
count = 0;

while True:

    grabbed, frame = video.read();

    if (grabbed):
        
        count += 1;
        timing = int(count / fps);

        cv2.putText(img=frame, text=str(timing), org=(150, 250), fontFace=cv2.FONT_HERSHEY_TRIPLEX, fontScale=3, color=(0, 255, 0),thickness=3)
        cv2.imshow("video", frame);

        # Press Q on keyboard to  exit
        if cv2.waitKey(25) & 0xFF == ord('q'):
            break   
    else:
        break;

video.release();
cv2.destroyAllWindows();

so while the video is playign im printing the current second of that frame, but for some reason the second and the frame arent the same as the original video, how can i do to show the accurate timing?

plus
  • 327
  • 3
  • 12
  • Pls check the below link it might help in answering your query. https://stackoverflow.com/questions/31472155/python-opencv-cv2-cv-cv-cap-prop-frame-count-get-wrong-numbers – Prasanna P Oct 10 '22 at 09:45

0 Answers0