Android MediaRecorder in streaming
Asked Answered
B

2

9

Its possible to "stream" result of MediaRecorder?

The unique method i can see is mediaRecorder.setOutputFile that receives a FileDescriptor. So i can write the result to a File or send via socket to receiver.

I tried the second solution but the result video is corrupted because is not "seekable" in stream.

The idea is to use the camera of android device to publish result to Red5.

Benetta answered 6/9, 2011 at 13:27 Comment(0)
B
3

Yes it is possible. Here is the sample code with FileDescriptor and socket:

    socket = new Socket("192.168.1.234",8888);
    ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.fromSocket(socket);

    mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mRecorder.setOutputFile(fileDescriptor.getFileDescriptor);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    try {
        mRecorder.prepare();
    } catch (IOException e) {
        Log.e(LOG_TAG, "prepare() failed");
    }

    mRecorder.start();
Blodget answered 7/12, 2016 at 5:38 Comment(1)
getFileDescriptor() instead of getFileDescriptor So, final result line will looks like mRecorder.setOutputFile(fileDescriptor.getFileDescriptor() );Atli
N
2

Yes, it possible, there are many examples for that. You can checkout sipdroid example. Or even Android IP camera which is much more simple.

Good Luck

Nahama answered 6/9, 2011 at 20:59 Comment(1)
Here's the relevant code. Seems to use a looped-back unix socket to get the data. Slightly hacky but not too much I think.Cuspidation

© 2022 - 2024 — McMap. All rights reserved.