准备工作:

1.安装nginx和rtmp模块

2.安装ffmepg(用来推流)

以上准备工作参见这篇博客:http://www.cnblogs.com/damiao/p/5231221.html

1.配置nginx

用记事本工具打开

/usr/local/etc/nginx/nginx.conf

找到server 修改

 server {
listen 8080;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root html;
add_header Cache-Control no-cache;
} location /dash {
# Serve DASH fragments
root /tmp;
add_header Cache-Control no-cache;
} #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;
#}
}

找到rtmp 修改下面这个地方

rtmp {
server {
listen 1935;
application live1 {
live on;
record off;
} # HLS # For HLS to work please create a directory in tmpfs (/tmp/hls here)
# for the fragments. The directory contents is served via HTTP (see
# http{} section in config)
#
# Incoming stream must be in H264/AAC. For iPhones use baseline H264
# profile (see ffmpeg example).
# This example creates RTMP stream from movie ready for HLS:
#
# ffmpeg -loglevel verbose -re -i movie.avi -vcodec libx264
# -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1
# -f flv rtmp://localhost:1935/hls/movie
#
# If you need to transcode live stream use 'exec' feature.
#
application hls {
live on;
hls on;
hls_path /usr/local/var/www/hls;
} # MPEG-DASH is similar to HLS application dash {
live on;
dash on;
dash_path /tmp/dash;
}
}
}

保存配置文件,重新加载nginx配置

/usr/local/Cellar/nginx-full/1.8.1/bin/nginx -s reload

2.进行推流

ffmpeg -loglevel verbose -re -i /Users/Rick/Movies/Demo.mov  -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/movie

然后你就可以在这个目录

/usr/local/var/www/hls

看到生成一个个ts的文件,还会生成一个movie.m3u8的文件

在Safari里输入地址查看视频(需要等movie.m3u8文件生成后),也可以用iPad或者iPhone上的Safari来访问(其他设备记得需要把localhost改为nginx的ip地址)

http://localhost:8080/hls/movie.m3u8

让nginx支持HLS的更多相关文章

  1. 转: 基于nginx的hls直播系统

    转自:http://blog.csdn.net/cjsafty/article/details/9108587 看点: 1. 详细解解答了 nginx rtmp配置过程. 前写了一篇基于nginx的h ...

  2. Nginx搭建hls流媒体服务器

    第一种方案:ffmpeg+nginx   新的ffmpeg已经支持HLS.(本人也参与了代码供献,给自己做个广告:))   点播:   生成hls分片:   ffmpeg -i <媒体文件> ...

  3. Nginx支持比Apache高并发的原因

    1.先从各自使用的多路复用IO模型说起:  select模型:(apache使用,由于受模块等限制,用的不多)   单个进程能够 监视的文件描述符的数量存在最大限制 select()所维护的 存储大量 ...

  4. 配置Nginx支持SSL SNI(一个IP绑定多个证书) 以及Haproxy实现多域名证书

    概述 传统的每个SSL证书签发,每个证书都需要独立ip,假如你编译openssl和nginx时候开启TLS SNI (Server Name Identification) 支持,这样你可以安装多个S ...

  5. Nginx 支持 WAF 防护功能实战

    WAF(Web Application Firewall),中文名称叫做“Web应用防火墙 WAF的定义是这样的:Web应用防火墙是通过执行一系列针对HTTP/HTTPS的安全策略来专门为Web应用提 ...

  6. Nginx 支持 CI 框架的配置并禁止使用 ip 访问

    #CIserver {        listen      80;        server_name www.ci.com;        index       index.php index ...

  7. 让服务器apache/iis/nginx支持.apk/ipa文件下载

    服务器iis支持.apk文件下载的设置 IIS服务器不能下载.apk文件的原因:iis的默认MIME类型中没有.apk文件,所以无法下载. IIS服务器不能下载.apk文件的解决办法:既然.apk无法 ...

  8. Nginx支持连接数的问题

    据网上有人说nginx的配置中: nginx支持的最大连接数与以下因素有关: worker_processes ; events { worker_connections ; } ulimit -a ...

  9. 配置nginx,支持php的pathinfo路径模式

    nginx模式默认是不支持pathinfo模式的,类似index.php/index形式的url会被提示找不到页面.下面的通过正则找出实际文件路径和pathinfo部分的方法,让nginx支持path ...

随机推荐

  1. Nginx ab压力测试

    20-ab压力测试及nginx性能统计模块 优化的启发,打开的文件太多 Nginx 错误日志显示,打开文件数太多 系统层面 more /proc/sys/net/core/somaxconn 单个Ng ...

  2. leaflet-velocity 参数

    本文地址: https://www.cnblogs.com/veinyin/p/10769611.html  leaflet-velocity 是 leaflet 绘制风场的一个插件,其控制参数如下所 ...

  3. 仿QQ聊天图文混排流程图【适用于XMPP】

      图文混排流程图.graffle4.8 KB   下面附上图片素材: 表情.zip692.5 KB     下面是字符串与图片的详细对应关系:                 "[呲牙]& ...

  4. 主流服务器apache,iis,tomcat,jboss,resion,weblogic,websphere的区别

    在互联网高速发展的今天,不同种类的网站大量涌现,每个人都在享受着网络服务带来的便利.而创建自己的个性化网站的门槛不断降低.从事网站架构,这种当年的绝对“”高科技“”绝活.也从it人员的专利“”沦落“” ...

  5. 从requests源码分析中学习python(一)

    v2ex同步更新:https://www.v2ex.com/t/500081 微信公众号:python学习开发 分析源码,看大神的代码是一种学习的好方法,让我从中学到很多以前不知道的知识,这次打算从大 ...

  6. ssh远程免密登录Linux

    一.在本地机器创建公钥,一路回车即可 ssh-keygen -t rsa 二.发送公钥到远程服务器端 如果是默认端口:scp id_rsa.pub user@ip:~/.shh 如果远程服务器设置的是 ...

  7. JavaScript深入解读

    JavaScript是运行在浏览器上的脚本语言.我们平时看到丰富多彩的网页,这要在很大程度上归功于JavaScript. 引子 学点儿历史 JavaScript在编程语言的阵营里也是老资格了.它诞生于 ...

  8. 输出联系变化的数字seq

    主要作用:输出联系变化的数字格式:Seq 分割符号 开始 间隔 结束开始默认是1,间隔默认是1,分隔符默认回车一位是结束,两位首末,三位首间隔末,没有四位,开始可以是负数主要参数:-f 指定格式打印- ...

  9. java 多重继承

    接口不仅仅只是一种更纯粹形式的抽象类,它的目标比这更高,因为接口是根本没有任何具体实现的--也就是说,没有任何与接口相关的存储,因此也就无法阻止多个接口的组合, 在导出类中,不强制要求必须有一个抽象的 ...

  10. 【论文阅读】Learning Spatial Regularization with Image-level Supervisions for Multi-label Image Classification

    转载请注明出处:https://www.cnblogs.com/White-xzx/ 原文地址:https://arxiv.org/abs/1702.05891 Caffe-code:https:// ...