2

I want to capture video without showing a preview. The android docs here say this is possible, but don't explain how:

http://developer.android.com/guide/topics/media/camera.html#capture-video

Note: It is possible to use MediaRecorder without creating a camera preview first and skip the first few steps of this process. However, since users typically prefer to see a preview before starting a recording, that process is not discussed here.

what are the "first few steps" to skip?

Thank you

user3203425
  • 2,919
  • 4
  • 29
  • 48

3 Answers3

2

You misinterpret the documentation. What it really says (emphasis mine):

It is possible to use MediaRecorder without creating a camera preview first and skip the first few steps of this process. However, since users typically prefer to see a preview before starting a recording, that process is not discussed here.

In other words, you can create a preview and immediately start recording. There is no hint that MediaRecorder will let you run a hidden recording session.

Moreover, I agree with the document that the added value of not starting preview before starting recording, is negligible.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • So u need a preview? – Jono Dec 01 '17 at 16:28
  • @jonney yes, you do. If you winder whether this preview must be visible in the screen, the answer is 'no, but'. Take 'users typically prefer to see a preview' as a strong warning. – Alex Cohn Dec 01 '17 at 20:29
  • probably the issue I am having on my latest stack flow question. Please have a look and let me know – Jono Dec 01 '17 at 20:48
1

You can just skip step 5 of configuring media recorder given in the above link and preview wont be shown. But user will be interested in viewing its preview.

Punit Vajpeyi
  • 196
  • 11
0

Even though the documentation states it is possible, most of SO answers say otherwise. Take a look at this answer (and the answers linked in it).

The work around this limitation is to create a 1 x 1 px SurfaceView and use it to display the camera preview.

Community
  • 1
  • 1
Edson Menegatti
  • 4,006
  • 2
  • 25
  • 40
  • I wonder if it's the same performance hit as to just put an opaque view on top of the full screen preview view? – user3203425 Oct 16 '15 at 18:34
  • That's a pretty good question. Given this is handled by the native layer, I'd guess the impact is pretty much the same. The preview size (set in the camera parameters) will probably have a bigger effect. – Edson Menegatti Oct 19 '15 at 10:52
  • On many devices, 1x1 preview happens to be a huge performance hit, much worse than 16x16. – Alex Cohn Dec 01 '17 at 20:31