Trouble saving recorded videofile on sdcard

All your problems with Audio, Video and Images.

Trouble saving recorded videofile on sdcard

Postby Flarebright » Wed Nov 25, 2009 3:44 pm

Hi

I am trying to build an application which allows me to record a video and saves it on the SD card.
So far it looks good but for the saving on the sd card part.
I get an error which I do not understand, or better said I do not understand how this error is produced.
I am new to android so my knowledge is limited. I hope it does not bother you to give me a hand.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. holder = getHolder();
  2.  
  3. holder.addCallback(this);
  4.  
  5. holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  6.  
  7. recorder = new MediaRecorder();
  8.  
  9. recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  10.  
  11. recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
  12.  
  13. recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  14.  
  15. recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT/*AMR_NB*/);
  16.  
  17. recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


The medierecorder and following the part where I try to save it.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. recorder.setOutputFile("/sdcard/test.3gp");
  2.  
  3. recorder.setPreviewDisplay(holder.getSurface());
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


LogCat gives me this when I try to start recording.

pid: 735
tag: IOException
message: java.io.filenotfoundexception: /sdcard/test.3gp


I hope anyone can help me with this.
If further informations are required I will be glad to provide them.

Regards Flare
Flarebright
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Nov 19, 2009 3:42 pm

Top

Postby qlimax » Wed Nov 25, 2009 7:42 pm

have you tried to do this before of setting the output file? (just to try it...) :?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  try {
  2.  
  3.         File file = new File("/sdcard/test.3gp");
  4.  
  5.    
  6.  
  7.         // Create file if it does not exist
  8.  
  9.         boolean success = file.createNewFile();
  10.  
  11.  
  12.  
  13.         //optional part
  14.  
  15.         if (success) {
  16.  
  17.             // File did not exist and was created
  18.  
  19.         } else {
  20.  
  21.             // File already exists
  22.  
  23.         }
  24.  
  25.     } catch (IOException e) {
  26.  
  27.     }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


bye
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby padde » Wed Nov 25, 2009 8:36 pm

And make sure you have the right permissions in your manifest.
Since 1.6 (i guess) you need a "WRITE_EXTERNAL_STORAGE" permission.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 14 guests