Record n minutes from a webcam

asked 2019-08-13 03:32:00 -0600

dev4all12358 gravatar image

Hello,

My goal is to create a tool with OpenCV to record stream from webcams. I want to record the n last minutes before a event. First I try to find a way with ffmpeg and gstream to do that but I don't achieve to do this. Then I try to do this with OpenCV.

I have two solutions, I can't simply record for example 2500 images on my computer with imwrite and then erase the oldest images with new frames. Or I can create a "tiny videos" 5 to 10 seconds" to record a portion of time and then as the images solutions,I erase the oldest videos and replace it with new solution.

The idea is to be able to get the last n minutes with the two solutions. For the first solution, in worst case, if the program crash, the last frame is not stored and I can see the last (n minutes -1 frames). In the second solution the last "tiny video" is broken and I can see the last (n minutes - 1 tiny video) and this is not really great even if it is for me the most optimise solution ...

Can someone give me advices or solutions for my problem.

Best regard.

edit retag flag offensive close merge delete

Comments

1

how would this be related or specific to opencv ?

berak gravatar imageberak ( 2019-08-13 03:39:01 -0600 )edit

Probably because I use OpenCV and I need advices to do and optimize it.

dev4all12358 gravatar imagedev4all12358 ( 2019-08-13 07:27:11 -0600 )edit

I guess what @berak means is that your are using the wrong tools in your shed to solve the problem. However if you want to dig a hole with a hammer, why not grabbing the framerate of your webcam initialized video capture, and then creating a video with videowriter, where the number of frames that you add to the video = FPS * 60?

StevenPuttemans gravatar imageStevenPuttemans ( 2019-08-19 09:09:25 -0600 )edit

any recommendations on what the best tool might be?

shini gravatar imageshini ( 2020-09-01 03:54:25 -0600 )edit

^^ yea, apply fizzbuzz to frame numbers ;)

(if you can solve fizzbuzz, that is ...)

berak gravatar imageberak ( 2020-09-01 09:36:06 -0600 )edit