just a knee-jerk here, but i think the problem 
might be that the recorder requires random access 
to the resource to write meta information etc. 
easy to rewind a file and update it, not so easy 
on a socket.....



>Can you explain better your problem ? Can you receive data side
>server ?
>
>On 19 Ott, 05:36, zongan liu <[email protected]> wrote:
>>  After several days of agonizing, ultimately did not solve the problem,
>>  is hereby published issue and hoping to get friends to help.
>>
>>  Requirements: The android to record video and transmitted through the
>>  socket means to save the file on the server (3gp file).
>>
>>  Question: 3gp files saved to the server, mobile player can't open, 3gp
>>  file encoding is not correct.
>>
>>  Note: stored in the phone's local system, 3gp files encoded in the
>>  correct format, mobile phone player to open.
>>
>>  android record code:
>>
>>  String hostname = "192.168.20.106";
>>                  int port = 1234;
>>                  try
>>                  {
>>                          socket = new 
>>Socket(InetAddress.getByName(hostname), port);
>>                  }
>>                  catch (UnknownHostException e)
>>                  {
>>                          e.printStackTrace();
>>                  }
>>                  catch (IOException e)
>>                  {
>>                          e.printStackTrace();
>>                  }
>>                  ParcelFileDescriptor pfd = 
>>ParcelFileDescriptor.fromSocket(socket);
>>                  mMediaRecorder = new MediaRecorder();
>>
>>                  // ŠËíuà»ó¨ïšéÆ †èo
>>                  mMediaRecorder.setOutputFile(pfd.getFileDescriptor());
>> 
>>mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
>> 
>>mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
>> 
>>mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
>>                  mMediaRecorder.setOutputFormat
>>  (MediaRecorder.OutputFormat.THREE_GPP);
>>                  mMediaRecorder.setVideoSize(176, 144);
>>                  mMediaRecorder.setVideoFrameRate(15);
>> 
>>mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
>> 
>>mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
>>                  mMediaRecorder.setMaxDuration(10000);
>>
>>  Server receives the data  code:
>>  public MultiThreadServer() throws IOException
>>          {
>>                  serverSocket = new ServerSocket(port);
>>                  // 
>> RuntimeìIavailableProcessor()ïš�...@ï'âÒìñëOånÕ„ìICPUêîñŽ.
>>                  executorService = 
>>Executors.newFixedThreadPool(Runtime.getRuntime
>>  ().availableProcessors() * POOL_SIZE);
>>
>>                  System.out.println("ïû‘ÒäÌ Ù Ø");
>>          }
>>
>>          public void service()
>>          {
>>                  while (true)
>>                  {
>>                          Socket socket = null;
>>                          try
>>                          {
>>                                  // 
>>êŽùæãqªß¡¨êŽ,ë¸óvãqªß‡¯çs󼡨êŽ,èAâÔêG…¢accept();ò½éßåöóß¡¨êŽ
>>                                  socket = serverSocket.accept();
>> 
>>//executorService.execute(new Handler(socket));
>>                                  new Thread(new Handler(socket)).start();
>>
>>                          }
>>                          catch (Exception e)
>>                          {
>>                                  e.printStackTrace();
>>                          }
>>                  }
>>          }
>>
>>  Handler class code:
>>
>>  public Handler(Socket socket)
>>          {
>>                  this.socket = socket;
>>                  d = new File("D:/ds");
>>                  if (!d.exists())
>>                  {
>>                          d.mkdirs();
>>                  }
>>
>>                  try
>>                  {
>>                          store = File.createTempFile("sdsd", ".3gp", d);
>>                          fos = new FileOutputStream(store);
>>                          socketIn = socket.getInputStream();
>  >                 }
>>                  catch (IOException e)
>>                  {
>>                          // TODO Auto-generated catch block
>>                          e.printStackTrace();
>>                  }
>>          }
>>
>>          public void run()
>>          {
>>                  try
>>                  {
>>                          System.out.println("New connection accepted " +
>>  socket.getInetAddress() + ":" + socket.getPort());
>>
>>                          while ((length = socketIn.read(buffer)) != -1)
>>                          {
>>                                  fos.write(buffer, 0, length);
>>                                  fos.flush();
>> 
>>System.out.println("ê„çðé ì¸íÜÅBÅBÅBÅB" + 
>>length);
>>                          }
>>
>>                          fos.flush();
>>                          store = null;
>>                          socketIn.close();
>>                  }
>>                  catch (IOException e)
>>                  {
>>                          e.printStackTrace();
>>                  }
>>                  finally
>>                  {
>>                          try
>>                          {
>>                                  fos.close();
>>                                  fos = null;
>>                                  store = null;
>>                                  if (socket != null)
>>                                          socket.close();
>>                          }
>>                          catch (IOException e)
>>                          {
>>                                  e.printStackTrace();
>>                          }
>>                  }
>>                  System.out.println("-----------------------------䯱¦");
>>          }
>>
>>  You help me find the cause of it, in this thank you. Given at the high
>>  score! ! !
>

-- 
jason.vp.engineering.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