Thank you for response.
Because i dont quite know ho to do it using HTTP server :)
For example how Apache can write input stream into mp4 file.
Could you please give me an example?


пятница, 24 августа 2012 г., 21:10:24 UTC+5 пользователь bob написал:
>
> Why not put the mp4 on an HTTP server?  Why would you write your own 
> server for this?
>
>
>
> On Friday, August 24, 2012 12:24:46 AM UTC-5, Sever wrote:
>>
>> I have code:
>>
>>     private MediaRecorder recorder;
>>>     
>>>     String hostname = "192.168.1.125";
>>>     int port = 1935;
>>>     Socket socket;
>>>     ParcelFileDescriptor pfd;
>>>     public void start()
>>>         {
>>>  
>>>     try {
>>>     socket = new Socket(InetAddress.getByName(hostname), port);
>>>     pfd = ParcelFileDescriptor.fromSocket(socket);
>>>     
>>>     } catch (UnknownHostException e) {
>>>     // TODO Auto-generated catch block
>>>     e.printStackTrace();
>>>     } catch (IOException e) {
>>>     // TODO Auto-generated catch block
>>>     e.printStackTrace();
>>>     }
>>>          
>>>       recorder.setOutputFile(pfd.getFileDescriptor()); 
>>>       //  String filename = String.format("/sdcard/%d.mp4", 
>>> System.currentTimeMillis());
>>>       // 
>>>       // recorder.setOutputFile(filename);
>>>        
>>>     try
>>>             {
>>>         recorder.prepare();
>>>                 recorder.start();
>>>             }
>>>             catch (IllegalStateException e)
>>>             {
>>>         e.printStackTrace();
>>>             }
>>>             catch (IOException e)
>>>             {
>>>         e.printStackTrace();
>>>             }
>>>         }
>>
>>
>> And Server side:
>>
>>     import java.io.DataInputStream;
>>>     import java.io.FileOutputStream;
>>>     import java.io.IOException;
>>>     import java.io.InputStream;
>>>     import java.net.ServerSocket;
>>>     import java.net.Socket;
>>>     
>>>     public class Server {
>>>     
>>>             public static void main(String[] args) 
>>>             {
>>>                            
>>>             try
>>>                     {
>>>                     System.out.println("create sock");
>>>                     ServerSocket svsock = new ServerSocket(1935);
>>>                            
>>>                     System.out.println("accept");
>>>                     Socket sock = svsock.accept();
>>>                     System.out.println("buffer read");
>>>                     
>>>                     FileOutputStream outFile = null;
>>>     
>>>     String filename = String.format("%d.mp4", 
>>> System.currentTimeMillis());
>>>                                     
>>>        try {
>>>                                             outFile = new 
>>> FileOutputStream(filename);
>>>                                             System.out.println(filename);
>>>                                     } catch (IOException e1) {
>>>                                             e1.printStackTrace();
>>>                                     }
>>>     
>>>                       InputStream is = new 
>>> DataInputStream(sock.getInputStream());
>>>                                     byte[] byteBuffer = new byte[1024];
>>>                                        
>>>                                     int allsize = 0;
>>>                                     while(sock.isConnected()) {
>>>                                             
>>>                                     int size = is.read(byteBuffer);
>>>                                             if (size == -1){
>>>                                                     break;
>>>                                             } else {
>>>                                                     
>>> outFile.write(byteBuffer, 0, size);
>>>                                             }
>>>                                             allsize += size;
>>>       
>>>                                     }
>>>                                     System.out.println("close size=" + 
>>> allsize);
>>>                                     outFile.close();
>>>                                     sock.close();
>>>                                                 
>>>                     }
>>>                     catch(Exception e)
>>>                     {
>>>                             e.printStackTrace();
>>>                     }       
>>>                     
>>>                     System.out.println("endmain");
>>>             }
>>>     }
>>
>>
>> I test it on Android 2.2.2 (HTC quiet brilliant) and all works fine. When 
>> I press "start" button Server create file and record data from stream to 
>> file. After this file is normally play in VLC player and etc.
>>
>>
>> But when I test it on Android 4.0.4 (Galaxy S2) Server create file and 
>> record data from stream to file but not play in VLC (and other players too) 
>> and give me error 
>>
>> mp4 error: MP4 plugin discarded (no moov,foov,moof box)
>>> avcodec error: Could not open �codec demux error: Specified event object 
>>> handle is invalid
>>> ps error: cannot peek
>>> main error: no suitable demux module for `file/:///C:/1345461283455.mp4'
>>
>>
>> I also try to upload this file to youtube, but after upload youtube give 
>> me error like file format is unsupported.
>>
>>
>> But Android 4.0.4 (Galaxy S2) succesfully create and then play file when 
>> I save it on phone memory (not stream to server)
>>
>> I think problem maybe on server side, or something changed on android 
>> 4.0.4.
>>
>> Please, help me.
>> Thanks in advance.
>>
>

-- 
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