Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android MediaRecoder writing it to a socket

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?

like image 598
Gidiyo Avatar asked Dec 16 '25 19:12

Gidiyo


1 Answers

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

like image 175
vanevery Avatar answered Dec 19 '25 11:12

vanevery



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!