Hello.
I am having some unexpected results, that I hope someone has an answer to.
Preface
My application, Currently running on JavaCV 1.1 is basically composed of:
one thread pr camera: reading and processing frames from live cameras, about 17-18 fps.
one thread pr camera: handling the result of the analysis.
one thread pr camera: for writing live video and analysis result to disk based on events.
The disk writing use FFMpegFrameRecorder with H264, CRF 29, profile superfast, mp4 filetype, video only (no audio), 15 fps as default.
On my test system I have a 8 core i7 processor. OS windows 10.
Running with one camera and forcing a disk write event, I can see the files growing as video is written.
During this writing the CPU's run at average 10-15%,
the Java memory is going up and down between 800-1200 MB,
and the native memory fluctuates in the same fashion as the java memory. (so the native memory is being reclaimed).
Actual issue
When I increase the cameras to 6, and then forcing disk-write events on all cameras (forcing write of a total of 12 files)
The CPU goes up to about 90-100% (good)
Java memory goes up and down between 3-5 GB (good)
But the native memory keeps climbing up to the roof, and the disk files does not get any data, the file-size is constant 0. (bad)
If I do not do anything, the computer runs out of memory. (very bad)
If I force a FFMpegFrameRecorder.stop(), all files are written successfully, and the native drops down to normal levels.
If I temporarily halt the java application (e.g. with a break-point), data is flushed down to the files, and native memory gets reclaimed.
Cause?
My best guess is that ffmpeg has a buffer that is not being flushed to disk, due to.. something? not getting enough CPU?
Remedy?
Is there any setting to ffmpeg i can try to make sure this does not happen?
Is there any API I could use (in conjunction with FFMpegFrameRecorder) to force flush to disk periodically?
Any other workaround I have not thought about?
Maybe I an not doing something correct?
start() when I begin recording
record(Frame frame) for each frame (no timestamp)
stop() when recording is finished.
My workaround
I temporarily stop(), then start() to explicitly split the files in 1 minute chunks to force free native memory, but that is not a good solution.
Thanks in advance, Frank