1

I want to be able to record a video, stop, then start again immediately (i.e. no lag). The problem is that between a stop and start, my phone loses up to 1.5 seconds while the MediaRecorder is stopped, set to the right state and restarted.

I posted the basis of my code on StackOverflow here.

An automated stop start of this code produced these key timings:

  • 510 (fractional seconds to stop the recording)
  • 490 (fs to release the camera)
  • 710 (fs to start a recording)

I have tried 2 mediarecorders, but end up with illegalstateexceptions and don't think the media recorder can be re-used.

According to the Android documentation, the mediarecorder object cannot be reused.

Is there a way to start another video recording immediately?

Community
  • 1
  • 1
JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
  • If you want absolutely zero lag, you will probably need to record continuously and break up the recording instead. What are you trying to do? – fadden Jun 28 '15 at 14:14
  • @fadden: I am not sure what HockeyJ is looking to do, but I have seen several unanswered SO questions around the problem that arises when trying to record a long video [link](http://stackoverflow.com/questions/15370375/android-media-recorder-causes-device-to-lock-after-long-periods-of-recording) A way around that would be to record in chunks. But stopping and starting causes a serious frame drop. – MarkJoel60 Sep 16 '15 at 20:49

1 Answers1

0

When the recording needs to be stopped, call the stop() method. If you want to continue recording after this, call reset() to force the MediaRecorder back to the idle state. Then reconfigure the data source to prepare the MediaRecorder again:

Medirecorder.start();
//something else...
Mediarecorder.stop();
//something else...

Medirecorder.reset(); //if you need recording continue
// start(), stop() or what if you need something else

Mediarecorder.release(); // everthing is over 

//if you need start again you should prepare() called before start()
Kaloglu
  • 1,651
  • 1
  • 20
  • 31