Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get video duration opencv python

import cv2

cap = cv2.VideoCapture("./video.mp4")
fps = cap.get(cv2.CAP_PROP_FPS)      # OpenCV2 version 2 used "CV_CAP_PROP_FPS"
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
duration = frame_count/fps

print('fps = ' + str(fps))
print('number of frames = ' + str(frame_count))
print('duration (S) = ' + str(duration))
minutes = int(duration/60)
seconds = duration%60
print('duration (M:S) = ' + str(minutes) + ':' + str(seconds))

cap.release()
Comment

PREVIOUS NEXT
Code Example
Python :: tracking mouse position tkinter python 
Python :: discord.py send image 
Python :: sklearn mean square error 
Python :: counter in sort python 
Python :: python web3 to wei 
Python :: how to create chess board numpy 
Python :: imbade image to jupyter notebook 
Python :: django foreign key field on delete do nothing 
Python :: import forms 
Python :: python read toml file 
Python :: create new django project 
Python :: install gtts 
Python :: create text in python if not exists 
Python :: how to extract month from date in python 
Python :: how to minimize command console python 
Python :: python display object attributes 
Python :: how to find where python is located 
Python :: string array to float array python 
Python :: how to rotate the x label for subplot 
Python :: How to develop a TCP echo server, in Python? 
Python :: python roll dice 100 times 
Python :: flask how to run app 
Python :: modify dict key name python 
Python :: python fiscal year prior 
Python :: bs4 from url 
Python :: django python install 
Python :: get all columns names starting with pandas 
Python :: python is not set from command line or npm configuration node-gyp 
Python :: wait for input python 
Python :: python format datetime 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =