Hello.

It is necessary to implement a cyclic buffer of the video stream coming from the camera of the mobile device, running Android 4.4. The point is that the standard MediaRecorder has a fixed VideoDuration, after which it triggers an event to save the video file. But for my tasks, this is absolutely not suitable.

Tell me which way to go in order to realize the "continuous" (cyclic) frame buffer of the video stream with the specified FPS = 25 frames / sec. And upload data only for a certain event.

Approximate block diagram of the buffer implementation:

Sample buffer

Suppose that our buffer implements FPS = 25 frames / sec., The duration (required size) of a video file at the output VideoDuration = 15 seconds, and we get that we need a buffer for FPS * VideoDuration = 375 frames.

For example, with a video resolution of 1024 x 786 pixels, and a pixel color depth, say 4 bits, it turns out the size of one frame is FrameSize = H * W * bit = 3219456 bits, and then it still needs to be multiplied by the number of stored frames 375, as a result the size of such a buffer It turns out to be (3219456 * 375) / 8/1024/1024, it turns out about 143 MB, agree to keep such a volume, and it is very difficult to work with it, in memory or in a file.

Consequently, it is also necessary to implement the frame compression and decompression algorithms when unloading from the buffer to the file.

Let it be not MediaRecorder in the full sense, but a class that implements only the recording of frames into the buffer with their subsequent unloading without sound.

In one of the personal correspondence on the current issue, with a competent specialist, he advised the following:

1) Either work directly with the camera, but then there will be a more hardware dependent application. For me, this option is not suitable. 2) Either write your video codec. But here for me in general a dark forest.

What actually tell and advise? Who had such problems?

The fact is that implementing this buffer turned out to be very difficult for me, therefore I actually ask you for help.

Thank. Sincerely.

    0