Android MediaRecorder in streaming

℡╲_俬逩灬. 提交于 2019-12-18 15:53:37

问题


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.


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/7320691/android-mediarecorder-in-streaming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!