Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Front Facing Camera - empty (0km) file or start failed on some devices
    primarykey
    data
    text
    <p>I had this problem with my app (ScareApp) that uses the front facing camera to record video. I "think" I've finally resolved the issue, so thought I would post it here for any developers that run into the same thing....</p> <p>Basically.. The android MediaRecorder allows you to define the Video and Audio Encoder, and according to the docs, DEFAULT can be used for each. However, this refers to the main camera's settings, which is often a far higher spec than the front facing camera. DEFAULT on the Droid Razr for example, selects an encoding (MPEG_4_SP) that isn't available for the Front facing camera, and this results in an empty (0kb) file being produced (or on some other devices a Camera 100 - start failed error).</p> <p>My other option was to use the CameraProfile.get method to lookup what the HIGH_QUALITY settings, but again, this by default uses the main camera. To get around this, you can set the ID of the front facing camera by using </p> <pre><code>CameraProfile.get(&lt;CameraID&gt;, CamcorderProfile.QUALITY_HIGH); </code></pre> <p>My current work around is as follows:</p> <pre><code>CamcorderProfile profile = CamcorderProfile.get(FrontFacingCameraId, CamcorderProfile.QUALITY_HIGH); if(profile != null) { _recorder.setAudioEncoder(profile.audioCodec); _recorder.setVideoEncoder(profile.videoCodec); }else { //default to basic H263 and AMR_NB if profile not found _recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); _recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263); } </code></pre> <p>Or alternatively, you can skip setting the Encoders, and just use</p> <pre><code>_recorder.setProfile(profile); </code></pre> <p>But as my app allows the user to select the resolution, I need to set the encoder's.</p> <p>Hopefully this will help someone and save the time and hassle it has caused me!</p> <p>Cheers, Mark</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload