yeah you probably want to capture to /sdcard/

/videotest.3gp most definitely is not writable to a regular android app!

other than that your code is pretty much the same as mine.



>Hi Jason, perhaps you could help me with my code. I was trying to
>capture video for two weeks now without success :(
>
>This is my complete code
>========================
>
>public class VideoCapture extends Activity
>       implements SurfaceHolder.Callback {
>
>       private static final String TAG = "JTrek Video Capture";
>       private SurfaceView surfaceView;
>     private SurfaceHolder surfaceHolder;
>     private MediaRecorder recorder;
>     private String videoFile = "videotest.3gp";
>
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         surfaceView = (SurfaceView)findViewById(R.id.surface);
>
>         surfaceHolder = surfaceView.getHolder();
>         surfaceHolder.addCallback(this);
>         surfaceHolder.setType
>(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>
>         setRequestedOrientation
>(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
>
>         prepareVideoCapture();
>     }
>
>     public void prepareVideoCapture() {
>       /* Create a MediaRecorder */
>       recorder = new MediaRecorder();
>       Log.i(TAG, "Media recorder created");
>
>       try {
>               OutputStream stream = openFileOutput(videoFile,
>MODE_WORLD_WRITEABLE);
>               stream.write(0xA);
>               stream.close();
>       } catch(IOException ioException) {
>               Log.e(TAG, "VIDEO: An error creating the output file.");
>               }
>
>       File file = getFileStreamPath(videoFile);
>       Log.i(TAG, "File exists? : " + file.exists());
>
>       recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
>       recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
>       recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
>       recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
>       recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
>
>       recorder.setOutputFile(this.videoFile);
>       Log.i(TAG, "Media recorder parameters set");
>
>       recorder.setPreviewDisplay(surfaceHolder.getSurface());
>       Log.i(TAG, "Preview Display set to surface holder!");
>     }
>
>   //
>============================================================================
>     //                                            SURFACE CALLBACK 
> IMPLEMENTATION
>     //
>============================================================================
>     public void surfaceCreated(SurfaceHolder holder) {
>         Log.e(TAG, "surfaceCreated");
>
>         try {
>             recorder.prepare();
>       } catch (IllegalStateException e) {
>             Log.e(TAG, e.toString());
>       } catch (IOException e) {
>             Log.e(TAG, "THE ERROR IS HERE!: " + e.toString());
>       }
>
>       Log.i(TAG, "Media recorder prepared for video capture!");
>
>         try {
>               recorder.start();
>       } catch (IllegalStateException e) {
>               Log.e(TAG, e.toString());
>       }
>       Log.i(TAG, "Video capture started!!");
>     }
>
>     public void surfaceChanged(SurfaceHolder holder, int format, int
>w, int h) {
>         Log.e(TAG, "surfaceChanged");
>     }
>
>     public void surfaceDestroyed(SurfaceHolder holder) {
>         Log.e(TAG, "surfaceDestroyed");
>     }
>     //
>============================================================================
>
>     protected void onStop() {
>       // Stops the media recorder object
>       recorder.stop();
>       recorder.release();
>
>         Log.e(TAG, "onStop");
>         super.onStop();
>     }
>}
>
>And this is the LogCat I received when debugging:
>=================================================
>
>08-17 10:51:22.400: INFO/Video Capture(709): Media recorder created
>08-17 10:51:22.450: INFO/Video Capture(709): File exists? : true
>08-17 10:51:22.571: INFO/Video Capture(709): Media recorder parameters
>set
>08-17 10:51:22.581: INFO/Video Capture(709): Preview Display set to
>surface holder!
>08-17 10:51:23.132: ERROR/Video Capture(709): surfaceCreated
>08-17 10:51:23.181: ERROR/Video Capture(709): THE ERROR IS HERE!:
>java.io.FileNotFoundException: /videotest.3gp
>08-17 10:51:23.191: INFO/Video Capture(709): Media recorder prepared
>for video capture!
>08-17 10:51:23.191: ERROR/MediaRecorder(709): start called in an
>invalid state: 4
>08-17 10:51:23.200: ERROR/Video Capture(709):
>java.lang.IllegalStateException
>08-17 10:51:23.210: INFO/Video Capture(709): Video capture started!!
>08-17 10:51:23.210: ERROR/Video Capture(709): surfaceChanged
>
>I am also wondering if it is mandatory to capture video in external
>memory instead of internal memory?
>Thanks in advance. I appreciate any help you can give me!..
>

-- 
jason.software.particle

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to