为什么80%的码农都做不了架构师?>>>   hot3.png

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>

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashVars = {
streamer: 'rtmp://192.168.1.2/myapp',
file:'test1'
};
swfobject.embedSWF("RtmpPlayer.swf", "rtmp-publisher", "500", "400", "9.0.0",null, flashVars);
</script>

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就可以了

转载于:https://my.oschina.net/doz/blog/69019

Android 使用Nginx rtmp 模块相关推荐

  1. Ubuntu中使用Nginx+rtmp模块搭建流媒体视频点播服务

    1. 背景 不知不觉来到流媒体部门已经一年半多了,也算积攒了不少的流媒体知识,平时工作比较忙,到没有对流媒体技术进行系统性的梳理:最近刚完成一个Git实用指南的技术专栏,放松一周之后,觉得还是得让自己 ...

  2. 笔记Mac下配置nginx+rtmp模块推流服务器碰到的问题:Error: This tap is now empty as all its formulae were migrated

    安装环境 ,Mac版本 : 10.13.5 在装的nginx版本为1.13.12 安装命令见:https://blog.csdn.net/zjuwwj/article/details/72773704 ...

  3. python搭建流媒体服务器_Linux自建直播服务器一:使用Nginx+rtmp模块搭建流媒体服务器...

    技术服务于生活.当在日常遇到问题的时候,需要经常去思考如何解决这个问题. 最近网易的逆水寒开测了,非常荣幸拿到一个资格号,可以来体验一下这款国产巅峰级网游,一个会呼吸的江湖.作为一个极度业余的主播(一 ...

  4. linux nginx添加rtmp,linux系统下nginx rtmp模块流媒体服务器

    1.准备以下源码包 nginx-1.14.0.tar.gz nginx-rtmp-module-master.zip openssl-1.0.2o.tar.gz pcre-8.42.tar.gz zl ...

  5. Nginx RTMP 功能研究

    Nginx-RTMP功能调研 1. RTMP协议介绍...2 2.RTMP server.3 2.1当前的流媒体server.3 2.2Wowza功能...3 3.Nginx-based RTMP s ...

  6. [转]Nginx RTMP 功能研究(Nginx流媒体)

    转自:http://blog.csdn.net/cccallen/article/details/8440191 看点: 1.    Nginx 配置信息与使用.  (支持 rtmp与HLS配置) 2 ...

  7. mac搭建nginx+rtmp直播流

    1.nginx安装 (1)克隆github的项目 brew tap denji/nginx (2)安装nginx+rtmp模块 brew install nginx-full --with-rtmp- ...

  8. 服务器搭建和使用 ubuntu_Ubuntu中使用Nginx+rtmp搭建流媒体直播服务

    一.背景 本篇文章是继上一篇文章<Ubuntu中使用Nginx+rtmp模块搭建流媒体视频点播服务>文章而写,在上一篇文章中我们搭建了一个点播服务器,在此基础上我们再搭建一个直播服务器, ...

  9. linux搭建直播步骤,Linux 下 nginx + rtmp 搭建直播服务

    简单粗暴直接上步骤吧: 注 : 以下示例使用的是nginx(版本1.15.3) rtmp(版本1.2.1) 下载nginx和rtmp模块 下载nginx 解压 ​ tar xvf nginx-1.15 ...

最新文章

  1. 【LeetCode】LeetCode之删除并获得点数——动态规划、排序+动态规划
  2. linux windows爆音,升级Windows 10后 部分情况下有爆音,杂音,音频卡顿现象
  3. 显卡天梯图:2014最新显卡性能天梯图
  4. 百度BAE JAVA环境项目部署和调试
  5. 周鸿祎,会是下一个“贾跃亭”吗?
  6. cmk聪明客机器人餐厅_晒晒我家85平新房,餐厅装修的太漂亮了,儿童房飘窗更实用!...
  7. 学习vue-router源码记录-1
  8. [英语阅读]憧憬利好新政股市收高
  9. 马云的B2B B2C 和C2C的“三合一”
  10. 番外4:自动进行功放输出阻抗匹配设计(匹配至4次谐波)
  11. 电路基础之:差模信号与共模信号
  12. C语言期末复习不挂科(快速入门)(和bug郭一起学C系列1)
  13. IDEA中pom文件变成了橘色
  14. 9.11云和恩墨笔试
  15. 计算机网络技术课程答案网课,《计算机网络技术》大学生网课答案.docx
  16. 英孚教育APP应用获全球杰出商业银奖
  17. HBase快速导入巨量数据—— Bulk Loading
  18. 聚类kmeans案例
  19. JAVA程序之矩形、三角形、平行四边形、菱形
  20. Binggo公开课 “CODEX创新体系”的实战演练-中关村创业大街

热门文章

  1. 使用XMLHttpRequest发送POST数据
  2. 利用计算机进行信息检索,用计算机进行情报检索属于计算机应用中的
  3. win11鼠标怎么在轮滑时只滚动一个屏幕 Windows11鼠标设置轮滑只滚动一个屏幕的步骤方法
  4. vsftp匿名访问目录_怎么更改vsftp匿名用户的默认登录目录/var/ftp?
  5. 去除maven父依赖_如何在Maven中从父项目中排除依赖项?
  6. commit git 删除文件夹_从Git提交中删除文件
  7. ar自回归 python_时间序列分析 | 向量自回归模型
  8. 字体系列之字体大小(CSS、HTML)
  9. 模型相关:SolidWorks创建Cube模型,在3DMax中给不同面添加不同颜色,导出自带纹理的FBX至Unity
  10. java 反复器_java集合类中的枚举器(反复器)