Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6044635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:02:02+00:00 2026-05-23T07:02:02+00:00

When the camera start to record my application throws this exception: E/MediaRecorder( 3316): setOutputFile

  • 0

When the camera start to record my application throws this exception:

E/MediaRecorder( 3316): setOutputFile called in an invalid state(2):
E/AndroidRuntime( 3316): java.lang.IllegalStateException
E/AndroidRuntime( 3316):        at android.media.MediaRecorder._setOutputFile(Native Method)
E/AndroidRuntime( 3316):        at android.media.MediaRecorder.prepare(MediaRecorder.java:542)
E/AndroidRuntime( 3316):        at com.android.cameradiag.VideoCamera.initializeRecorder(VideoCamera.java:448)
E/AndroidRuntime( 3316):        at com.android.cameradiag.VideoCamera.startVideoRecording(VideoCamera.java:638)

My code is:

mMediaRecorder = new MediaRecorder();

// Unlock the camera object before passing it to media recorder.
mCameraDevice.unlock();
mMediaRecorder.setCamera(mCameraDevice);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// mMediaRecorder.setProfile(mProfile);
mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);

// Set output file.
if (mStorageStatus != STORAGE_STATUS_OK) {
    mMediaRecorder.setOutputFile("/dev/null");
} else {
    // Try Uri in the intent first. If it doesn't exist, use our own
    // instead.

    createVideoPath();
    mMediaRecorder.setOutputFile(mVideoFilename);

}

mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
try {
    mMediaRecorder.prepare();
} catch (IOException e) {
    Log.e(TAG, "prepare failed for " + mVideoFilename, e);
    releaseMediaRecorder();
    throw new RuntimeException(e);
}

I found the recorded 3gp file exists on the SDCard but it has a size of 0 bytes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:02:03+00:00Added an answer on May 23, 2026 at 7:02 am

    Before using mMediaRecorder.setOutputFile(mVideoFilename); you have to set the output format.

    See the flowchart on MediaRecorder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking at a tutorial, this one to be exact - http://android-er.blogspot.com/2011/01/start-camera-auto-focusing-autofocus.html And
I want to make a camera application in which i want to start front
I am working now on application that start the camera and take a photo,
My application allows it's user to start a camera intent to take pictures to
I start an IMAGE_CAPTURE Intent like this, and my activity's onActivityResult() get called: Intent
I’m developing an application, which allows to record video from web camera. (using visual
i'm trying the camera preview This is my code and it doesn't throw any
I am invoking camera from my application. i want to remove few menu items
I want to embed the native camera application into custom form. The RECT r
I'm currently writing a application that needs to capture some images. I start the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.