Using @roymacdonald 's buffer loop code works well for delays of a few seconds… I can even set a delay of 5 minutes, but it uses up to 22% of my CPU and pushes my memory usage up to 95%… video playback itself was riddled with spikes of slowdown and speedup.
So what if I want a delay of say, up to an hour? Is there, say, a way to write the video to hard disk and also read it at the same time?
I’ll have to do the same thing with audio as well so any tips for that’d be appreciated too.
And while I’m here, does anyone have any ideas of what to do about an hd webcam (Logicool C920) running at only 4 fps when set to 1920x1080 ? It runs at about 30pfs when I set the ofVideoGrabber to 800x448, but that’s hardly ideal. This post by someone with the same problem didn’t seem to offer any good solutions for Windows users and that ofxGStreamer plugin is scary- having last been tested on VS2012!
For long camera delays you will have to record the data to disk. The memory usage you get from the buffer loop is becuase it is storing the video data in RAM, so it will fill up fast. You could write the files to disk as frames, there is a threaded image saver example on the forum somewhere you can take a look at. With a fast hard drive and a threaded image loader you could get long video delay (until your hard drive is full) and playback from any point pretty fast.
if you need audio as well, this means recording video files or trying to sync frames with audio which will be hard to do exactly. There is an addon that uses ffmpg to record videos that can help.
This will help, but you cannot read a file until it is finished writing, and this can take some time depending on the file format and length. You may be best off recording smaller chunks and trying to play them sequentially. To do this will likely use quite some resources.
If it is a critical feature I would look at using some kind of external video recorder that can do this easily. Some models of the blackmagic hyperdeck will allow you to do this with a little trickery (using timecode, and two recorders you can make sure you have all the frames recording even when you are playing back). This method is not free, but not super expensive, considering how long it would take to make a system from scratch that can do this, and what your time is worth this may make sense. Check this out:
You can set up a similar system, and you can use the rs422 port to control the deck so you dont need to implement the full proprietry black magic control protocol and then you can control everything programatically.
Hope this helps.
@fresla Thank you for the thorough reply! I’ve tried ofxVideoRecorder and am having this exact problem, so I guess I’ll have to try “ofxFastFboReader with ofxFFmpegRecorder from Nick repos” as advised in the last post there…