流媒体中的Android MediaRecorder [英] Android MediaRecorder in streaming

查看:34
本文介绍了流媒体中的Android MediaRecorder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以流式传输"MediaRecorder 的结果?

Its possible to "stream" result of MediaRecorder?

我能看到的唯一方法是接收 FileDescriptor 的 mediaRecorder.setOutputFile.所以我可以将结果写入文件或通过套接字发送到接收器.

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.

想法是使用android设备的摄像头将结果发布到Red5.

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

推荐答案

是的,这是可能的.这是带有 FileDescriptor 和套接字的示例代码:

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

这篇关于流媒体中的Android MediaRecorder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆