I want to capture the frames of video with timestamps in real time using Raspberry pi. The video is made by USB webcam using ffmpeg()
function in python code. How do I save the frames of video which is currently made by USB webcam in Raspberry pi?
I tried using three functions of opencv. cv2.VideoCapture to detect the video, video.read()
to capture the frame and cv2.imwrite()
to save the frame.Here is the code, the libraries included is not mentioned for conciseness.
os.system('ffmpeg -f v4l2 -r 25 -s 640x480 -i /dev/video0 out.avi')
video=cv2.VideoCapture('out.avi')
ret, frame=video.read()
cv2.imwrite('image'+str(i)+'.jpg',frame)
i+=1
The code saves the frames of video which was previously made by webcam. It is not saving the frames of video which is currently being recorded by webcam.
currently being recorded
? Do you mean video still under recording and not yet flushing to a file? – mootmoot