大疆无人机基于RTMP服务推流直播

流程:配置nginx服务器--->打开服务器---->配置无人机rtmp地址,将无人机画面推流到服务器上---->运行vlc从服务器上拉取视频流播放。

学习视频链接(可借鉴):https://www.youtube.com/watch?v=QNEjTGQL7wc

一、在linux服务器中(ubuntu18.04)下载安装docker容器,docker分为docker engine 和 docker desktop

我们安装docker engine就可以了。

官网链接:

https://www.docker.com/

二、 下载docker镜像,可以参考下面github

GitHub - TareqAlqutami/rtmp-hls-server: a docker file to create a streaming server that supports RTMP, HLS and DASH content based on nginx and nginx-rtmp-module.

sudo docker pull alqutami/rtmp-hls    # pull拉取,  alqutami/rtmp-hlsdocker镜像

配置文件, 创建一个文件,名为nginx.conf  将下述代码复制进去。保存


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


rtmp {
    server {
        listen 1935;
        chunk_size 4000;
        application live {
             live on;
        }
    }
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
 

或者去下载nginx软件包:  nginx news

在nginx-1.8.0\conf\nginx.conf文件中增加关于rtmp的设置rtmp { server { listen 1935; chunk_size 4000; application live { live on; } } }

listen: 1935是监听端口号, application中 (live)是自己定义,在后面推流的时候用到。

 上述操作完成后执行下述代码,开启服务器。其中 /home/wby/nginx.conf是文件保存的路径

sudo docker run -d -p 1935:1935 -p 8080:8080 -v /home/wby/nginx.conf:/etc/nginx/nginx.conf alqutami/rtmp-hls

问题一:

出现如下报错: 

 可能是虚拟机容器id占用,输入如下代码查看

sudo docker ps -a    # 查看docker容器中运行的虚拟机

 如上:确实是虚拟机容器id占用,由于第一个4b5bf0ad35ca没有创建成功,可以直接删除虚拟机

sudo docker rm 虚拟机容器id

 第二个e9262d003c92是创建成功并处于运行状态,所以不能直接删除,如下是直接删除报错。

 此时需要先停止运行,

 然后再删除上面的容器id  

sudo docker rm e9262d003c92

打开服务器:

sudo docker run -d -p 1935:1935 -p 8080:8080 -v /home/wby/nginx.conf:/etc/nginx/nginx.conf alqutami/rtmp-hls

现在nginx服务器已经打开。  

三、配置无人机            

打开大疆无人机                                                                                                                                                                                                                    rtmp地址:192.168.X.XXX  是本机服务器的ip地址。       

rtmp://192.168.X.XXX:1935/live/home                                                                点击开始,此时大疆无人机可以向nginx服务器推流。

四、在电脑端下载安装VLC(https://www.videolan.org/vlc/

点击vlc.exe --->媒体--->打开网络串流---->选择网络

  

 输入网络串流,注意ip地址和上面无人机设置的一致。

                                                                                                                                                             播放效果如下:

 上面是无人机的推流过程。 

                                                                                                                                                        五、如果想通过rtmp推流播放本地视频进行测试。                                                                            需要多一步操作,                                                                                                                                上面第一步和第二步不变,安装docker下载docker镜像,然后打开nginx服务器。

    在本地下载ffmpeg推流工具,下载链接如下:                                                                                                                                                                                                                

Download FFmpeg

选择一个合适的版本 ,下载并解压

 

 nginx服务器打开后,打开cmd进入ffmpeg.exe存放的文件夹输入:ffmpeg.exe -re -i 使用nginx-rtmp打造简易直播系统.mp4 -vcodec libx264 -acodec copy -f flv rtmp:/192.168.3.72/live/home

如上,则表示推流成功。

然后执行上面第四步,打开vlc播放器。  

  • 7
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值