Android流到rstp服务器并使用nginx转换为rtmp

时间:2017-06-10 12:16:09

标签: android nginx ffmpeg rtsp rtmp

我试图让我的Android设备将其相机直播到网络浏览器。 我在androidhive上阅读了一篇关于使用wowza的精彩教程。但是,我正在寻找一个免费的解决方案。 我决定在我的本地机器上安装一个带有rtmp模块的nginx服务器,可以从局域网外部访问。 我能够毫无问题地使用OBS流式传输我的屏幕。

MY SETTINGS:

在nginx中,我正在使用以下内容:

rtmp {
    server {
        listen 1935;
        allow play all;
        chunk_size 4000;

        application live {
            live on;
            allow publish all;
            allow play all;

            exec_pull c:/nginx/ffmpeg -i "rtsp://127.0.0.1:1935/live/test" -f flv -r -s -an "rtmp://127.0.0.1:1935/live/pc"

            #enable HLS
            hls on;
            hls_path "c:/nginx/www/hls";
            hls_fragment 3;
            hls_playlist_length 60;
        }
    }
}

我真的不确定关于ffmpeg ......

的界限

在我的android应用程序中,它很简单,我在这里从androidhive教程中学习了这个类:http://www.androidhive.info/2014/06/android-streaming-live-camera-video-to-web-page/ 我正在使用libstreaming for android:https://github.com/fyhertz/libstreaming

因此,我只需使用以下行创建RTSP客户端:

    Matcher m = uri.matcher("rtsp://127.0.0.1:1935/live/test");

它应创建一个RTSP客户端,使用RTSP协议连接到127.0.0.1:1935,并将摄像机流式传输到“测试”通道中的“实时”应用程序。 所以我的nginx应该在端口1935上收到一些东西并使用ffmpeg将RTSP转换为RTMP吗?

我缺少什么使整个工作有效?我真的陷入了困境并试图尝试

谢谢!

1 个答案:

答案 0 :(得分:0)

使用10.0.2.2 - 主机环回接口(127.0.0.1)的特殊别名

更改

Matcher m = uri.matcher("rtsp://127.0.0.1:1935/live/test");

Matcher m = uri.matcher("rtsp://10.0.2.2:1935/live/test");
相关问题