views:

79

answers:

2

Hi,

Currently, I am using Android MediaRecorder class to record video and writing it to a file.

recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);

recorder.setOutputFile("/sdcard/recordtest.m4e"); But is there anyway I can write it to a socket?

A: 

It is probably better to read from the file in another thread and send that to a socket.

In response to your specific question: You can open a Socket, get a ParcelFileDescriptor and pass that into the MediaRecorder's setOutputFile method.

This page describes how, complete with pseudo code: http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system

vanevery
Looks promising... but an exception raise: Connection Refused. Even I set the socket address to local host 127.0.0.1
Gidiyo
127.0.0.1 would be the phone itself. You will have to be running a SocketServer on some port for that to work. Are you specifying a port?
vanevery
I think you'll have to go through this tutorial: http://download.oracle.com/javase/tutorial/networking/sockets/clientServer.html
vanevery