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 6934931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:01:40+00:00 2026-05-27T12:01:40+00:00

I am trying to record video and save to an external SD card. However,

  • 0

I am trying to record video and save to an external SD card. However, everytime I am getting three errors

anyone knew of any tutorials or could help correct my code.

could any one help me as i am getting this three errors

    12-09 14:12:23.592: E/AndroidRuntime(4377): java.lang.NullPointerException
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at com.mahesh.VideoStreamActivity.surfaceChanged(VideoStreamActivity.java:71)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.view.SurfaceView.updateWindow(SurfaceView.java:568)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.view.SurfaceView.access$000(SurfaceView.java:82)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:171)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1590)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2382)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.os.Handler.dispatchMessage(Handler.java:99)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.os.Looper.loop(Looper.java:137)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at android.app.ActivityThread.main(ActivityThread.java:4340)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at java.lang.reflect.Method.invokeNative(Native Method)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at java.lang.reflect.Method.invoke(Method.java:511)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    12-09 14:12:23.592: E/AndroidRuntime(4377):     at dalvik.system.NativeStart.main(Native Method)
    12-09 14:17:02.723: E/CAMERA_TUTORIAL(4596): /data/data/com.mahesh/cache/sdcard/videooutput: open failed: ENOENT (No such file or directory)

12-09 14:17:02.723: W/System.err(4596): java.io.FileNotFoundException: /data/data/com.mahesh/cache/sdcard/videooutput: open failed: ENOENT (No such file or directory)
12-09 14:17:02.734: W/System.err(4596):     at libcore.io.IoBridge.open(IoBridge.java:406)
12-09 14:17:02.734: W/System.err(4596):     at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
12-09 14:17:02.734: W/System.err(4596):     at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
12-09 14:17:02.734: W/System.err(4596):     at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
12-09 14:17:02.734: W/System.err(4596):     at android.media.MediaRecorder.prepare(MediaRecorder.java:623)
12-09 14:17:02.734: W/System.err(4596):     at com.mahesh.VideoStreamActivity.startRecording(VideoStreamActivity.java:119)
12-09 14:17:02.734: W/System.err(4596):     at com.mahesh.VideoStreamActivity.surfaceCreated(VideoStreamActivity.java:50)
12-09 14:17:02.743: W/System.err(4596):     at android.view.SurfaceView.updateWindow(SurfaceView.java:562)
12-09 14:17:02.743: W/System.err(4596):     at android.view.SurfaceView.access$000(SurfaceView.java:82)
12-09 14:17:02.743: W/System.err(4596):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:171)
12-09 14:17:02.743: W/System.err(4596):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
12-09 14:17:02.743: W/System.err(4596):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1590)
12-09 14:17:02.743: W/System.err(4596):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2382)
12-09 14:17:02.743: W/System.err(4596):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 14:17:02.743: W/System.err(4596):     at android.os.Looper.loop(Looper.java:137)
12-09 14:17:02.743: W/System.err(4596):     at android.app.ActivityThread.main(ActivityThread.java:4340)
12-09 14:17:02.753: W/System.err(4596):     at java.lang.reflect.Method.invokeNative(Native Method)
12-09 14:17:02.753: W/System.err(4596):     at java.lang.reflect.Method.invoke(Method.java:511)
12-09 14:17:02.753: W/System.err(4596):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-09 14:17:02.753: W/System.err(4596):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-09 14:17:02.753: W/System.err(4596):     at dalvik.system.NativeStart.main(Native Method)
12-09 14:17:02.753: W/System.err(4596): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
12-09 14:17:02.753: W/System.err(4596):     at libcore.io.Posix.open(Native Method)
12-09 14:17:02.753: W/System.err(4596):     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
12-09 14:17:02.763: W/System.err(4596):     at libcore.io.IoBridge.open(IoBridge.java:390)
12-09 14:17:02.763: W/System.err(4596):     ... 20 more
12-09 14:17:02.773: D/AndroidRuntime(4596): Shutting down VM
12-09 14:17:02.773: W/dalvikvm(4596): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
12-09 14:17:02.793: E/AndroidRuntime(4596): FATAL EXCEPTION: main
12-09 14:17:02.793: E/AndroidRuntime(4596): java.lang.RuntimeException: setParameters failed
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.hardware.Camera.native_setParameters(Native Method)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.hardware.Camera.setParameters(Camera.java:1253)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at com.mahesh.VideoStreamActivity.surfaceChanged(VideoStreamActivity.java:68)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.view.SurfaceView.updateWindow(SurfaceView.java:568)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.view.SurfaceView.access$000(SurfaceView.java:82)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:171)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1590)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2382)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.os.Looper.loop(Looper.java:137)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at android.app.ActivityThread.main(ActivityThread.java:4340)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at java.lang.reflect.Method.invokeNative(Native Method)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at java.lang.reflect.Method.invoke(Method.java:511)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-09 14:17:02.793: E/AndroidRuntime(4596):     at dalvik.system.NativeStart.main(Native Method)

    code>>>>>>>>>>>>>>>>>>>>>>>>>
    import java.io.File;
    import java.io.IOException;

    import android.app.Activity;
    import android.graphics.PixelFormat;
    import android.hardware.Camera;
    import android.media.MediaRecorder;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.SurfaceHolder;
    import android.view.SurfaceView;
    import android.widget.Toast;

    public class VideoStreamActivity extends Activity implements SurfaceHolder.Callback{

        private static final String TAG = "CAMERA_TUTORIAL";

        private SurfaceView surfaceView;
        private SurfaceHolder surfaceHolder;
        private Camera camera;
        private boolean previewRunning;
        private MediaRecorder mediaRecorder;
        private final int maxDurationInMs = 20000;
        private final long maxFileSizeInBytes = 500000;
        private final int videoFramesPerSecond = 20;
        private File tempFile;



        String cacheFileName="/sdcard/videooutput";

            @Override
            public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.camera_surface);
                    surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
                    surfaceHolder = surfaceView.getHolder();
                    surfaceHolder.addCallback(this);
                    surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
            }

            @Override
        public void surfaceCreated(SurfaceHolder holder) {
            camera = Camera.open();
            if (camera != null){
                Camera.Parameters params = camera.getParameters();
                camera.setParameters(params);

            }
            else {
                Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
                finish();
            }
        }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            if (previewRunning){
                camera.stopPreview();
            }
            Camera.Parameters p = camera.getParameters();
            p.getPreferredPreviewSizeForVideo();
            p.setPreviewSize(width, height);

            p.setPreviewFormat(PixelFormat.JPEG);

            camera.setParameters(p);

            try {
                camera.setPreviewDisplay(holder);
                camera.startPreview();
                previewRunning = true;
            }
            catch (IOException e) {
                Log.e(TAG,e.getMessage());
                e.printStackTrace();
            }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            camera.stopPreview();
            previewRunning = false;
            camera.release();
        }



        public boolean startRecording(){
            try {
                camera.unlock();

                mediaRecorder = new MediaRecorder();

                mediaRecorder.setCamera(camera);
                mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

                mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);

                mediaRecorder.setMaxDuration(maxDurationInMs);


                tempFile = new File(getCacheDir(),cacheFileName);

                mediaRecorder.setOutputFile(tempFile.getPath());

                mediaRecorder.setVideoFrameRate(videoFramesPerSecond);
                mediaRecorder.setVideoSize(surfaceView.getWidth(), surfaceView.getHeight());

                mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
                mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

                mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());

                mediaRecorder.setMaxFileSize(maxFileSizeInBytes);

                            mediaRecorder.prepare();
                mediaRecorder.start();

                return true;
            } catch (IllegalStateException e) {
                Log.e(TAG,e.getMessage());
                e.printStackTrace();
                return false;
            } catch (IOException e) {
                Log.e(TAG,e.getMessage());
                e.printStackTrace();
                return false;
            }
        }

        public void stopRecording(){
            mediaRecorder.stop();
            camera.lock();
        }
    }
  • 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-27T12:01:41+00:00Added an answer on May 27, 2026 at 12:01 pm

    Take a look at file path you’re opening:

    /data/data/com.mahesh/cache/sdcard/videooutput
    

    It looks like you’re opening file using incorrect path. Without code its hard to tell anything else.

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

Sidebar

Related Questions

Im trying to record video using AVFoundation I can save images but not video.
I'm trying to record video with camera in android, but any output format i
I'm trying to use android.media.MediaRecorder to record video, and no matter what I do
I'm trying to associate a video file to a record with a bunch of
i am developing an application in which i am trying to record a video
I am trying to record and play video simultaneously. Is this possible with avfoundation?
I am trying to record a video on my android project. I have found
I am trying to record video using AVFoundation. When I add video input only
I'm trying to record a video while the iPhone playback an audio track. as
I am trying to record a video in OpenCV from a stream such as

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.