开发者

Android MediaRecorder in streaming

开发者 https://www.devze.com 2023-04-03 03:48 出处:网络
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 t

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.


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


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号