Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

record video with python

import cv2 # make sure you have open-cv installed
# credit to http://www.learningaboutelectronics.com
# slightly edited by WoefulDeveloper (me)

cap = cv2.VideoCapture(1)

width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
video_speed = 50 # higher number means faster frame rate
video_name = "Video.mp4"
writer = cv2.VideoWriter(video_name,cv2.VideoWriter_fourcc(*'DIVX'), video_speed, (width,height))

while True:
    ret,frame = cap.read()
    writer.write(frame)
    cv2.imshow('frame', frame) # not necessary you can comment this out
    if cv2.waitKey(1) & 0xFF == 27: # waits for the "esc" key to stop the video
        break

cap.release()
writer.release()
cv2.destroyAllWindows()
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib plot two graphs side by side 
Python :: pip install speedtest 
Python :: how to append to text file with new line by line in python 
Python :: console clear python 
Python :: reverse dictionary python 
Python :: median of a list python 
Python :: python copy file and rename 
Python :: How to convert an integer number into words in python? 
Python :: char to binary python 
Python :: how to get unix timestamp in python 
Python :: capture output of os.system in python 
Python :: matplotlib remove ticks and lines 
Python :: pandas drop zero values 
Python :: py sleep function 
Python :: print two digits after decimal python 
Python :: pandas capitalize column 
Python :: django python base 64 encode 
Python :: python set env var 
Python :: learn python the hard way pdf 
Python :: pyqt5 change button color 
Python :: python check operating system 
Python :: python console animation 
Python :: get current month name python 
Python :: how to get user location in python 
Python :: how to detect a keypress tkinter 
Python :: get video duration opencv python 
Python :: django settings variables 
Python :: python3 as default python path macos 
Python :: how to do forward feature selection in python 
Python :: python get minute from datetime 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =