Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Saved video file is showing zero bytes.

Saved video file is showing zero bytes.

All your problems with Audio, Video and Images.

Saved video file is showing zero bytes.

Postby Themaskofwraith » Wed Sep 09, 2009 11:31 am

hi my video recording application recording the video,but the saved file is only 0bytes.anyone help me.
my code is:

1)for video preview:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.work.camerautil;
  3.  
  4.  
  5.  
  6. import java.io.IOException;
  7.  
  8.  
  9.  
  10. import android.content.Context;
  11.  
  12. import android.hardware.Camera;
  13.  
  14. import android.view.SurfaceHolder;
  15.  
  16. import android.view.SurfaceView;
  17.  
  18.  
  19.  
  20. public class Preview extends SurfaceView implements SurfaceHolder.Callback {
  21.  
  22.      SurfaceHolder m_cHolder;
  23.  
  24.      Camera m_cCamera;
  25.  
  26.      
  27.  
  28.      
  29.  
  30.      boolean m_cState=false;
  31.  
  32.  
  33.  
  34.      Preview(Context context) {
  35.  
  36.           super(context);
  37.  
  38.  
  39.  
  40.           // Install a SurfaceHolder.Callback so we get notified when the
  41.  
  42.           // underlying surface is created and destroyed.
  43.  
  44.           m_cHolder = getHolder();
  45.  
  46.           m_cHolder.addCallback(this);
  47.  
  48.           m_cHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  49.  
  50.          
  51.  
  52.      }
  53.  
  54.  
  55.  
  56.      public void surfaceCreated(SurfaceHolder holder) {
  57.  
  58.           // The Surface has been created, acquire the camera and tell it where
  59.  
  60.           // to draw.
  61.  
  62.          m_cCamera = Camera.open();
  63.  
  64.           try {
  65.  
  66.                   m_cCamera.setPreviewDisplay(holder);
  67.  
  68.           } catch (IOException e) {
  69.  
  70.                // TODO Auto-generated catch block
  71.  
  72.                e.printStackTrace();
  73.  
  74.           }
  75.  
  76.          
  77.  
  78.      }
  79.  
  80.  
  81.  
  82.      public void surfaceDestroyed(SurfaceHolder holder) {
  83.  
  84.           // Surface will be destroyed when we return, so stop the preview.
  85.  
  86.           // Because the CameraDevice object is not a shared resource, it's very
  87.  
  88.           // important to release it when the activity is paused.
  89.  
  90.           m_cCamera.stopPreview();
  91.  
  92.           m_cCamera = null;
  93.  
  94.      }
  95.  
  96.  
  97.  
  98.      public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
  99.  
  100.           // Now that the size is known, set up the camera parameters and begin
  101.  
  102.           // the preview.
  103.  
  104.           Camera.Parameters parameters = m_cCamera.getParameters();
  105.  
  106.           // Camera.par
  107.  
  108.           parameters.setPreviewSize(w, h);
  109.  
  110.           m_cCamera.setParameters(parameters);
  111.  
  112.           m_cCamera.startPreview();
  113.  
  114.      }
  115.  
  116.  
  117.  
  118.    
  119.  
  120. }
  121.  
  122.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4

2)for capturing video
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.work.camerautil;
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. import java.io.IOException;
  11.  
  12.  
  13.  
  14. import android.app.Activity;
  15.  
  16. import android.app.AlertDialog;
  17.  
  18. import android.content.DialogInterface;
  19.  
  20. import android.content.Intent;
  21.  
  22. import android.content.DialogInterface.OnClickListener;
  23.  
  24. import android.media.MediaRecorder;
  25.  
  26. import android.os.Bundle;
  27.  
  28. import android.view.Menu;
  29.  
  30. import android.view.MenuItem;
  31.  
  32. import android.view.SurfaceHolder;
  33.  
  34. import android.view.SurfaceView;
  35.  
  36.  
  37.  
  38.  
  39.  
  40. public class Capture extends Activity {
  41.  
  42.      private static final int START_VIDEO = 1;
  43.  
  44.         private static final int SAVE_VIDEO = 2;
  45.  
  46.         private static final int EXIT = 3;
  47.  
  48.         private static final int LOCATION = 4;
  49.  
  50.        
  51.  
  52.         private Preview mPreview;
  53.  
  54.      SurfaceView sv;
  55.  
  56.      AndroidFileBrowser m_cBrowser;
  57.  
  58.      SurfaceHolder holder;
  59.  
  60.      MediaRecorder m_cRecorder = new MediaRecorder();
  61.  
  62.    
  63.  
  64.  
  65.  
  66.      /** Called when the activity is first created. */
  67.  
  68.      @Override
  69.  
  70.      public void onCreate(Bundle savedInstanceState) {
  71.  
  72.           super.onCreate(savedInstanceState);
  73.  
  74.           mPreview = new Preview(this);
  75.  
  76.           setContentView(mPreview);
  77.  
  78.          
  79.  
  80.           m_cRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  81.  
  82.           m_cRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
  83.  
  84.           m_cRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  85.  
  86.           m_cRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
  87.  
  88.           m_cRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
  89.  
  90.           m_cRecorder.setOutputFile("/sdcard/DCIM/100ANDRO/test28.mp4");
  91.  
  92.  
  93.  
  94.      }
  95.  
  96.  
  97.  
  98.      
  99.  
  100.      public boolean onCreateOptionsMenu(Menu pMenu) {
  101.  
  102.          pMenu.add(0,START_VIDEO,0,"Capture");
  103.  
  104.           pMenu.add(0,SAVE_VIDEO,0,"Save");
  105.  
  106.           pMenu.add(0,EXIT,0,"Exit");
  107.  
  108.           pMenu.add(0,LOCATION,0,"open");
  109.  
  110.                    return true;
  111.  
  112.      }
  113.  
  114.  
  115.  
  116.      public boolean onOptionsItemSelected(MenuItem pItem) {
  117.  
  118.           switch(pItem.getItemId()){
  119.  
  120.           case LOCATION:
  121.  
  122.                                         next();
  123.  
  124.                         return true;
  125.  
  126.           case START_VIDEO:
  127.  
  128.                           try {
  129.  
  130.                                   m_cRecorder.prepare();
  131.  
  132.                                         } catch (IllegalStateException e) {
  133.  
  134.                                                 // TODO Auto-generated catch block
  135.  
  136.                                                 e.printStackTrace();
  137.  
  138.                                         } catch (IOException e) {
  139.  
  140.                                                 // TODO Auto-generated catch block
  141.  
  142.                                                 e.printStackTrace();
  143.  
  144.                                         }
  145.  
  146.                                         try{
  147.  
  148.                                                 m_cRecorder.start();
  149.  
  150.                                         }catch(Exception e){
  151.  
  152.                                                 e.toString();
  153.  
  154.                                         }
  155.  
  156.                                 return true;
  157.  
  158.              
  159.  
  160.         case SAVE_VIDEO:               
  161.  
  162.                                 saveVideo();
  163.  
  164.                         return true;
  165.  
  166.                        
  167.  
  168.         case EXIT:
  169.  
  170.                                 finish();
  171.  
  172.                         return true;
  173.  
  174.        
  175.  
  176.                                         }
  177.  
  178.           return false;
  179.  
  180.      }
  181.  
  182.      public void saveVideo(){
  183.  
  184.                
  185.  
  186.                                 try{
  187.  
  188.                                         m_cRecorder.stop();
  189.  
  190.                                         //m_cRecorder.reset();
  191.  
  192.                                         m_cRecorder.release();
  193.  
  194.                                         }catch(Exception e){
  195.  
  196.                                                 e.toString();
  197.  
  198.                                         }
  199.  
  200.                                
  201.  
  202.                        
  203.  
  204.          
  205.  
  206.      }
  207.  
  208.  
  209.  
  210. }
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


3)my manifest file
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.      package="com.work.camerautil"
  7.  
  8.      android:versionCode="1"
  9.  
  10.      android:versionName="1.0">
  11.  
  12.       <uses-permission android:name="android.permission.CAMERA" />
  13.  
  14.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  15.  
  16.         <activity android:name=".Capture"
  17.  
  18.                  android:label="@string/app_name">
  19.  
  20.             <intent-filter>
  21.  
  22.                 <action android:name="android.intent.action.MAIN" />
  23.  
  24.                 <category android:name="android.intent.category.LAUNCHER" />
  25.  
  26.             </intent-filter>
  27.  
  28.         </activity>
  29.  
  30.     </application>
  31.  
  32.     <uses-sdk android:minSdkVersion="3" />
  33.  
  34. </manifest>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


thanks for ur help.
Regards:
maskofwraith
Themaskofwraith
Freshman
Freshman
 
Posts: 4
Joined: Wed Aug 26, 2009 2:40 pm
Location: India

Top

Postby ximian » Thu Sep 10, 2009 10:52 am

Hi Pal,

You may want to set

recorder.setPreviewDisplay(yoursurfaceholder.getSurface());
recorder.prepare();
recorder.start();

You need to set the preview before capturing. Mine works.
ximian
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Sep 01, 2009 4:41 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 13 guests