user1291510
user1291510

Reputation: 265

Very slow fps at webcam streaming

I have been working on a little webcam program in java that captures images from the webcam and then streams the video feed to another program (on another computer) with a socket.

So far I does stream video, but at about 1-5 fps where it should be able to stream at about 30 fps

The server sends an int array with RGB data through te socket. The code looks like this:

The client/reciver

try{    
                Object o;
                o = objInStream.readObject();
                if(o != null){

                    if(o instanceof int[]){
                        videoFeed.setRGB(0,0,640,480,(int[]) o, 0, 640);
                        repaint();
                    }
                }
            }catch(Exception ex){
                System.out.println("Error: " + ex.getMessage());
            }

And the sender is just an ObjectOutputStream:

outStream.send(image); <--- image is an int[] of RGB data. outStream.flush();

then thread sleeps for(10 milliseconds).

A video of the contraption can be seen here: http://www.youtube.com/watch?v=esAMHOdoOUk Note: The version in the video is just displaying image to the local computer.

Upvotes: 2

Views: 1013

Answers (1)

Tudor
Tudor

Reputation: 62469

You're probably using a TCP socket for transfer. TCP has a lot of overhead associated, so it's really not suitable for fast video streaming.

I suggest you try a UDP socket instead, which is a very fast (albeit unreliable) protocol.

Upvotes: 0

Related Questions