Python and OpenCV - getting the duration time of a video at certain points

Hafiz Hilman Mohammad Sofian

Let say I have made a program to detect a green ball in a video. Whenever there is a green ball detected, I want to print out the duration of video at the time the green ball is detected. Is it possible?

DomTomCat

In this answer, you will find a solution to determine the frames per second.

so you'd want to use:

fps = cap.get(cv2.cv.CV_CAP_PROP_FPS)

and count the number of frames you're at. Then you can compute the video time with

videotime = current_frame_number / fps.

EDIT:

@Miki suggested to use CAP_PROP_POS_MSEC which should result in the same time (in [ms])

Corrected my typo as pointed out by @Swiper-CCCVI

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python and OpenCV - getting the duration time of a video at certain points

From Dev

Duration of a video (OpenCV)

From Dev

to add event listener for getting video duration in run time in videojs

From Dev

Video / Movie Duration Time

From Dev

Video / Movie Duration Time

From Dev

Record video of a certain time using OpenCV in C++

From Dev

Time duration by timedelta in python

From Dev

OpenCV-Python : Issue with getting frame rate of video

From Dev

python opencv display time countdown using putText in webcam video

From Dev

Start playing a video at a certain time

From Dev

java jetty json getting request time and duration

From Dev

openCV video saving in python

From Dev

OpenCV (Python) video subplots

From Dev

No video output OpenCV Python

From Dev

Read a video in opencv (python)

From Dev

Python opencv video writer

From Dev

How to get video full duration and current playing time?

From Dev

How to increase time duration of taking a video of Android Studio

From Dev

how to get the time duration video watched in iOS app

From Dev

How to increase time duration of taking a video of Android Studio

From Dev

How to remove audio from a specific time duration of a video

From Dev

Youtube API - call a function at certain time in the video

From Dev

Saving a video capture in python with openCV : empty video

From Dev

Saving a Video in OpenCV (Linux, Python)

From Dev

Cannot open video in OpenCV (Python)

From Dev

Overlay video onto another video at multiple points in time

From Dev

How to pause a video after a certain time? video.js

From Dev

Calculating the duration an event in a time series python

From Dev

Getting Notification after a certain time in Android

Related Related

HotTag

Archive