Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Endless Video Recording

Tags:

android

video

I am building an app that will hold a 60 second buffer of recorded video. The video recording needs to run for an extended period of time (24-48 hours). I do not seem to have any issues with recording, but it appears that I lose the connection with my Camera or Surface after a few hours of time.

I am setting the max duration: MediaRecorder.setMaxDuration(10 * 1000) so that recording is broken up into 10 second segments.

Each time I restart my recording I am incrementing the output file in such a way that 6 files are reused. The purpose is to keep a 60 second history at all times.

If I stop the recording after 1-2 hours the videos play back fine. However, if I let it run for 3-4+ hours and stop the recording, the videos shows only black output with audio. In other words, it is as if it lost a connection with the camera or surface but continued recording audio.

Can anyone explain this behavior?

If nothing else, is there a better way to record X second segments of video?

FYI: I am using a wake lock so that the screen/CPU stay on.

like image 551
Tanner Perrien Avatar asked Nov 05 '22 16:11

Tanner Perrien


1 Answers

I have sort of answered my own question here. I don't have a lot of information, but hopefully this will provide enough information to help others in a similar predicament.

First, I never posted my code because it's way too lengthy. I didn't post snippets of my code because I did not know where the problem was originating. Despite the fact that I have this working now, I still do not know what was wrong with my old code.

My suggestion:

I ended up scrapping my code and starting fresh with the code found in the Development API Demos: CameraPreview -- I found this references in at least one thread on this site.

After that I was able to continually record for hours on end without problem. So if you are in a similar situation, I would suggest using the CameraPreview code as a starting point.

like image 171
Tanner Perrien Avatar answered Nov 16 '22 12:11

Tanner Perrien