srs(simple Rtmp Server )的一些说明

简介:

    srs 是国人自己开发的一款视频服务器,采用支持rtmp和hls协议,可以做成容器,让客户端把流推过来来,也可以结合ffmpeg自己主动拉流,详细的说明可以查看srs的wiki:

https://github.com/ossrs/srs/wiki/v2_CN_Home

srs下载地址:http://ossrs.net/srs.release/releases/index.html

srs网页播放器:http://www.ossrs.net/players/srs_player.html?stream=livestream&port=19350#

ffmpeg下载地址:http://www.ffmpeg.org/download.html

或者:wget  http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz 


自己工作中采用的编译参数:    

./configure --prefix=/usr/local/srs --with-hls --with-hds --with-dvr --without-nginx --with-ssl --with-ffmpeg --with-transcode --with-ingest --with-stat --with-http-callback --with-http-server --without-stream-caster --with-http-api --with-librtmp --with-research --with-utest --without-gperf --without-gmc --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace

make

make install 

ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs


srs做成容器的配置:

    

listen              1935;

max_connections     1000;

pid                 objs/edge.pid;

srs_log_file        ./objs/edge.log;

vhost __defaultVhost__ {

}

    

srs集群的配置:

listen              1935;

max_connections     1000;

pid                 objs/edge.pid;

srs_log_file        ./objs/edge.log;

vhost __defaultVhost__ {

    mode            remote;

    origin          127.0.0.1:19350;

}

    把origin里面的127.0.0.1:19350改成可以提供数据源的srs服务器监听的socket,提供数据源的srs服务可以做成容器让别人推送,也可以自己分发


srs配置分发rtmp流:

listen              1935;

max_connections     1000;

pid                 objs/edge.pid;

srs_log_file        ./objs/edge.log;

vhost __defaultVhost__ {

ingest livestream {

        enabled      on;

        input {      

            type    stream;   

            url    rtmp://58.218.152.98:1935/hls/j2--;

        }

        ffmpeg      ./objs/ffmpeg/ffmpeg-;

        engine {

            enabled          on;

            output          rtmp://127.0.0.1:1935/live/livestream;

        }

    }

}

    type如果是文件的话要改成file,url是流的地址,采用这种配置需要安装ffmpeg


srs配置hls分发:

listen              1935;

max_connections     1000;

pid                 objs/edge.pid;

srs_log_file        ./objs/edge.log;

vhost __defaultVhost__ {

ingest livestream {

        enabled      on;

        input {

            type    stream;

            url    rtmp://58.218.152.98:1935/hls/j2--;

        }

        ffmpeg      ./objs/ffmpeg/ffmpeg;

        engine {

            enabled          on;

            output          rtmp://127.0.0.1:1935/live/livestream;

        }

    }

 hls {

        enabled         on;

        hls_fragment    10;

        hls_window      60;

        hls_path        ./objs/nginx/html;

        hls_m3u8_file   [app]/[stream].m3u8;

        hls_ts_file     [app]/[stream]-[seq].ts;

    }

}

http_server {

    enabled         on;

    listen          8088;

    dir             ./objs/nginx/html;

}

    hls是采用点播的方式实现直播,把视频差不多大小的片,每个片以.ts结尾,并生成一个  流名.m3u8  作为索引,所以看hls分发有没有生效直接查看http_server里面的dir目录有没有生成这两个文件


下面是实际生产环境中遇到过的问题:

1,视频采集不了,但是加-bsf:a aac_adtstoasc就可以采集

解决方法:直接修改srs的配置文件edge.conf 在engine里面添加aparams并增加,例子如下:

ingest livestream {

        enabled      on;

        input {

            type    stream;

            url http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8; 

        }

        ffmpeg      /tmp/ffmpeg;

        engine {

            enabled         on;

            vcodec          copy;

            acodec          copy;

            aparams 

 {

profile:a   aac_low;

                bsf:a       aac_adtstoasc;

            }

            output          rtmp://127.0.0.1:1935/live/livestream;

        }

    }


2.视频可以正常采集但是用vlc放不了,用完美解码和特殊软件可以

解决方法:加-vsync drop参数(注意:这个只是个人的解决方法,恰好可以用,并不准确,更多的是编码问题),然后加-r 30 解决播放卡帧问题,最终ffmpeg采集参数如下:

 /usr/local/src/ffmpeg -r 30 -i rtmp://23.33.33.118/live/11  -vsync drop -vcodec copy  -c:v copy -report -an -f flv -y rtmp://127.0.0.1:1935/live/11


3.视频播放正常,但是没有音频,查看日志提示:

【warn】[9642][239][11] aac  ignore type=1 for  no sequence header.ret=0


解决:用系统自带的ffmpeg或自己编译的ffmpeg,可能是有些编译好的ffmpeg二进制程序没有对应音频编码功能导致的,并在配置文件中 把acodec 选项选为对应音频编码格式,如果使用hls分片,有时候还要指定hls_acodec,例如:

  hls_acodec      aac;

















本文转自biao007h51CTO博客,原文链接:http://blog.51cto.com/linzb/1776029 ,如需转载请自行联系原作者
相关文章
|
Web App开发 应用服务中间件 nginx
利用Simple-RTMP-Server(SRS)来进行直播
1、下载SRS 官方地址:http://www.ossrs.net/srs.release/releases/ 百度地址:http://pan.baidu.com/s/1kV8WQpx   2、编译安装SRS tar zxvf srs-2.0-b2.tar.gz cd srs-2.0-b2 mv trunk/ /usr/local/srs cd /usr/local/srs  ./configure --full     #--full,开启SRS所有的功能。
2738 0
|
3月前
|
NoSQL 容器 消息中间件
rtsp-simple-server + srs搭建流媒体服务器
rtsp-simple-server + srs搭建流媒体服务器
179 0
|
9月前
UE Http Server Plug -in description
UE Http Server Plug -in description
64 0
|
编解码
gstreamer之RTSP Server编译及注意事项
gstreamer之RTSP Server编译及注意事项
361 0
gstreamer之RTSP Server test-mp4正确运行代码
gstreamer之RTSP Server test-mp4正确运行代码
102 0
|
应用服务中间件 PHP 开发工具
Swoole based Simple HTTP Server Implementation using OSS PHP SDK
Currently, program developers are leveraging Swoole to implement network server programs in place of C++, Java and other complex programming languages.
4307 0
|
应用服务中间件 nginx
利用Simple-RTMP-Server搭建RTMP和HLS直播服务(上)
SRS(Simple-RTMP-Server)定位是运营级的互联网直播服务器集群,追求更好的概念完整性和最简单实现的代码,在Github上人气颇高。
5284 0
|
移动开发 Windows
A simple in-process HTTP server for UWP
原文 http://www.dzhang.com/blog/2012/09/18/a-simple-in-process-http-server-for-windows-8-metro-apps 简单来说,就是在UWP中做一个支持GET请求简单的Web Server,本实例UWP(server) 与 Winform(client) 在同一机子将无法通讯,但UWP(server)写client代码可调用调试。
1589 0