android rtmp server,使用nginx在android手机上搭建rtmp服务器并测试

1,编译android上面可以使用的nginx,添加选项--add-module=/path/nginx-rtmp-module,准备android上面shell可以使用的ffmpeg和相关库文件以及m3u8的segmenter文件 2,在手机的data/data/android.nginx目录下把编译生成的nginx相关文件放到该目录下 3,编写配置文件 -----------------------------------nginx.conf start here---------------------------------------------------- user  root; worker_processes  2; error_log  /data/data/android.nginx/logs/error.log; error_log  /data/data/android.nginx/logs/error.log  notice; error_log  /data/data/android.nginx/logs/error.log  info; pid        logs/nginx.pid; events {     worker_connections  1024; } rtmp {     server {         listen 1935;         chunk_size 4096;         application myapp {             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      801;         location /stat {             rtmp_stat all;             rtmp_stat_stylesheet stat.xsl;         }         location /stat.xsl {             root /data/data/android.rtmp;         }         location / {             root /data/data/android.rtmp/test/rtmp-publisher;         }     }     server {         listen      80 default;         server_name  localhost;         autoindex            on;         autoindex_exact_size on;         root    /data/data/android.wwwroot;         index   index.html index.htm index.php;         #charset koi8-r;         #access_log  logs/host.access.log  main;         #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$ {             fastcgi_index  index.php;             client_max_body_size 64m;             fastcgi_pass   unix:/data/data/android.php-fpm/tmp/php-fpm.socket;             fastcgi_param  SCRIPT_FILENAME  /data/data/android.wwwroot$fastcgi_script_name;             include        fastcgi_params;         }     location ~ \.flv$ {                          flv;                         }        location ~ \.mp4$ {                          mp4;                         }         # 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  default;     #    listen       somename:8080;     #    server_name  somename  alias  another.alias;     #    location / {     #        root   html;     #        index  index.html index.htm;     #    }     #}     # HTTPS server     #     #server {     #    listen     443 default;     #    server_name  localhost;     #    ssl                  on;     #    ssl_certificate      cert.pem;     #    ssl_certificate_key  cert.key;     #    ssl_session_timeout  5m;     #    ssl_protocols  SSLv2 SSLv3 TLSv1;     #    ssl_ciphers  HIGH:!aNULL:!MD5;     #    ssl_prefer_server_ciphers   on;     #    location / {     #        root   html;     #        index  index.html index.htm;     #    }     #} } -----------------------------------nginx.conf end here---------------------------------------------------- 4,adb push nginx.conf /data/data/android.nginx/conf/ 5,启动nginx,在/data/data/android.nginx目录下,执行./nginx -c ./conf/nginx.conf 6,准备ffmpeg文件 adb shell su chmod 777 /system/bin/ adb push ffmpeg /system/bin/ adb shell su cd system/bin chmod 777 ffmpeg exit exit adb push libvorbisenc.so.2 /system/lib adb push libvorbis.so.0 /system/lib adb push libogg.so.0 /system/lib adb push libtheoraenc.so.1 /system/lib adb push libtheoradec.so.1 /system/lib adb push libmp3lame.so.0 /system/lib adb push libfdk-aac.so.0 /system/lib adb push segmenter /system/bin adb shell su cd /system/bin chmod 777 segmenter exit exit 7,准备相关文件 adb push 1.flv /data/data/android.wwwroot/ 8,准备rtmp相关文件 在/data/data/目录下建立rtmp目录,使用adb push的方法把nginx-rtmp-module目录下所有文件push到/data/data/rtmp目录下 修改该目录下的./test/rtmp-publisher/player.html ---------------------------player.html start here--------------------------------------------------------------- !DOCTYPE html>

    RTMP Player            
       

Flash not installed

   
---------------------------player.html end here--------------------------------------------------------------- 9,推流 "rtmp://192.168.1.2/myapp"表示url, "test1"表示stream 推流方式1:ffmpeg -re -i 1.flv -f flv rtmp://192.168.1.2/myapp/test1 注意:要把相关文件push到 我这里把这个简单写成pushrtmp的批处理 ---------------------------------pushrtmp start here----------------------------------------------------------- !/system/bin/sh     file=$1     file_name=`echo ${file} | busybox awk -F '.' '{ print $1 "" }'`       ffmpeg -re -i ./$1.flv -f flv rtmp://192.168.1.$2/myapp/test1 ---------------------------------pushrtmp end here----------------------------------------------------------- 执行方式就是简单的./pushrtmp 1 2就可以了 10,测试 在另一台机器上访问http://192.168.1.2:801/player.html就可以了
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值