working means, server create an image file but when i open it, it will not show me an image as I write on sd card and FTP is to send file I don't want to send a file, I am sending an onpreviewfram byte array that is in jpeg format to server and then save it to image file.
basically my project is to capture video from the android camera and send it to TCP socket and server will receive this video in a a file. thanks Date: Sun, 27 Nov 2011 22:30:13 +0530 Subject: Re: [android-developers] Please help me!!! how to create video file on server side by send onPreviewFrames byte array From: [email protected] To: [email protected] What do you mean by not working? Are you getting a specific error? What does the LogCat say? Try adding breakpoints to your code. Also, in my personal opinion, it would be easier to send the images via HTTP or FTP. See this for FTP upload: http://stackoverflow.com/questions/6464456/how-do-you-upload-images-to-an-ftp-server-within-an-android-app. On Sun, Nov 27, 2011 at 10:23 PM, Muhammad UMER <[email protected]> wrote: Hi Raghav, Thanks for your reply, I am using the TCP socket to send data to my server.i am writing image files continuously to sd card is perfet. but send this to server is not working. /////// Here is my client side code public void onPreviewFrame(byte[] data, Camera camera) { // <11> Camera.Parameters parameters = camera.getParameters(); int format = parameters.getPreviewFormat(); //YUV formats require more conversion if (format == ImageFormat.NV21 /*|| format == ImageFormat.YUY2 || format == ImageFormat.NV16*/) { int w = parameters.getPreviewSize().width; int h = parameters.getPreviewSize().height; // Get the YuV image YuvImage yuv_image = new YuvImage(data, format, w, h, null); // Convert YuV to Jpeg Rect rect = new Rect(0, 0, w, h); ByteArrayOutputStream output_stream = new ByteArrayOutputStream(); yuv_image.compressToJpeg(rect, 100, output_stream); byte[] byt=output_stream.toByteArray(); FileOutputStream outStream = null; try { /////// this work perfect for sd card //outStream = new FileOutputStream(String.format( // "/sdcard/%d.jpg", System.currentTimeMillis())); //outStream.write(byt); //outStream.close(); // this method write byte array to socket sendBytes(byt, 0, byt.length); Log.d(TAG, "onPreviewFrame - wrote bytes: " + data.length); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { } Preview.this.invalidate(); // Convert from Jpeg to Bitmap //bmap = BitmapFactory.decodeByteArray(output_stream.toByteArray(), 0, output_stream.size()); } ////////// sending byte array to server public void sendBytes(byte[] myByteArray, int start, int len) throws IOException { if (len < 0) throw new IllegalArgumentException("Negative length not allowed"); if (start < 0 || start >= myByteArray.length) throw new IndexOutOfBoundsException("Out of bounds: " + start); // Other checks if needed. // May be better to save the streams in the support class; // just like the socket variable. DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); //BufferedOutputStream imagebos = new BufferedOutputStream(dos); dos.writeInt(len); if (len > 0) { /// this will write to socket imagebos.write(myByteArray, start, len); } } ////// here is server side code ///////// while(dataInputStream.readInt() > 0 ) { //// reading from client ////read from client in byte array int len = dataInputStream.readInt(); byte[] data = new byte[2800000]; //// how to specify the length in run time if (len > 0) { dataInputStream.readFully(data); //dataInputStream.read(data); System.out.println("message: " + data); } //// write this data array on a file FileOutputStream fos = new FileOutputStream("image.jpg", true); ObjectOutputStream out = new ObjectOutputStream(fos); out.write(data); out.flush(); out.close(); fos.close(); } the server side code is correct or not but the file is not in correct formate, please tell me if i am doing wrong. Also tell me is it correct method to combine the images file to create a video? Please correct me if i m doing wrong Thanks umer Date: Sun, 27 Nov 2011 18:36:34 +0530 Subject: Re: [android-developers] Please help me!!! how to create video file on server side by send onPreviewFrames byte array From: [email protected] To: [email protected] Use any one of the numerous methods to send the files to your server (HTTP, FTP etc). You can use something on the server to combine them into a video. What you do on the server is not part of the Android SDK, and hence doesn't belong on the list. Thansk On Sun, Nov 27, 2011 at 6:29 PM, [email protected] <[email protected]> wrote: Hi, i am able to create images on sd card with onPreviewFrame by converting the raw byte array to Yuvimage and then compressing it to jpeg format and then write in a file. this work perfectly. but i want to send these preview frames to server and recored in a video file. please help me, I m stuck here thanks and Regards umer -- 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 -- Raghav Sood http://www.androidactivist.org/ - Authorhttp://www.appaholics.in/ - Founder -- 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 -- 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 -- Raghav Sood http://www.androidactivist.org/ - Authorhttp://www.appaholics.in/ - Founder -- 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 -- 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

