Streaming video from a camera on Android

I am trying to create an application that will broadcast video from an Android phone’s camera over the Internet using TCP or UDP. Currently, I can transfer an array of bytes from an android phone to a computer running a server that I wrote in C #. I already did streaming video, sending .jpeg over the network and showing them at a speed of 30 frames per second, but this increases the bandwidth too much.

First, what would be the best way to capture camera images? I look...

onPictureTaken(byte[] data, Camera camera)

or

onPreviewFrame (byte[] data, Camera camera)

I'm only interested in byte [] data, which receive and encode / compress it, and then send it over the network.

Secondly, how can I include these frames in compressed video, which is an array of bytes that can be transmitted over the network? I don’t care about the quality of the video, I care more about reducing bandwidth.

Here is what I'm trying to do, but I don’t need high quality video. https://code.google.com/p/spydroid-ipcamera/

+5
source share
2 answers

if you plan to encode the data yourself using any encoder, then the user

onPreviewFrame (byte[] data, Camera camera)

Or you can try another way by sending rtsp stream. SpyDroid is a very good project to see how to learn about this method.

+4
source

, , JPEG-? data byte YUV, JPEG. JPEG , .

 public void onPreviewFrame(byte[] data, Camera camera){

 YuvImage image = new YuvImage(data, ImageFormat.NV21,
                            size.width, size.height, null);
 baos = new ByteArrayOutputStream();
 int jpeg_quality = 100;

 image.compressToJpeg(new Rect(0, 0, size.width, size.height),
                         jpeg_quality, baos);

 byte[] sending_array = baos.toByteArray();

} 

size

Camera.Size size = parameters.getPreviewSize();
0

All Articles