欢迎光临
我们一直在努力

开源流媒体相关分享

rtsp vlc

<div id="play_area2" align="center" style="width:calc(100% – 210px);z-index: 19810823; float:left;"></div>
function rebuildRtsp(num){
var video_width = $("#play_area2").width();
var video_height = $("#show_vedio2").height()-20;
sendDataWithAjax("video/getRtspByNum","munitsId="+cur_id+"&deviceId="+num,function (rtsp){
var obj_html ='<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" id="vlc" events="true" >'+
' <param name="MRL" value="'+rtsp+'" />'+
' <param name="ShowDisplay" value="true" />'+
' <param name="AutoLoop" value="true" />'+
' <param name="AutoPlay" value="true" />'+
' <param name="Volume" value="50" />'+
' <param name="toolbar" value="true" />'+
' <param name="StartTime" value="0" />'+
' <EMBED pluginspage="http://www.videolan.org" '+
' type="application/x-vlc-plugin" '+
' version="VideoLAN.VLCPlugin.2" '+
' toolbar="false" '+
' loop="true" '+
' text="Waiting for video" '+
' width="'+video_width+'" '+
' height="'+video_height+'" '+
' name="vlc"> '+
' </EMBED> '+
'</object> ' ;
$("#play_area2").empty()[0].innerHTML = obj_html;
$("#vlc").width(video_width)
$("#vlc").height(video_height)
});

}

利用nginx和ffmpeg将rtsp转成rtmp

https://blog.csdn.net/FlyLikeButterfly/article/details/87546323

ffmpeg.exe -i "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov" -c:v copy -c:a copy -f flv "rtmp://localhost:1935/live/test"

https://streamedian.com/

https://github.com/Streamedian/html5_rtsp_player

1ip 不限时间 不限路数 495美元

安装flashplayer
https://get.adobe.com/cn/flashplayer/
http://ip:8083/video/index.html

搭建RTSP转发服务器

https://www.jianshu.com/p/a287e4e9fec3

webrtc

多人视频通讯常用架构Mesh/MCU/SFU
mediasoup/Licode/kurento/Janus/Medooze/jitsi
https://my.oschina.net/u/3937935/blog/4331261

Janus

Centos 安装Janus
详细过程请参考:https://github.com/meetecho/janus-gateway

yum install -y epel-release && \\
yum update -y && \\
yum install -y deltarpm && \\
yum install -y openssh-server sudo which file curl zip unzip wget && \\
yum install -y libmicrohttpd-devel jansson-devel libnice-devel glib22-devel opus-devel libogg-devel pkgconfig gengetopt libtool autoconf automake make gcc gcc-c++ git cmake libconfig-devel openssl-devel gettext-devel

# libsrtp主要是是用来加密rtp/rtcp的
# 开源安全RTP库
wget https://github.com/cisco/libsrtp/archive/v2.3.0.tar.gz
tar xfv v2.3.0.tar.gz
cd libsrtp-2.3.0
./configure –prefix=/usr –enable-openssl
make shared_library && make install

#为sip网关插件安装sofi -sip
wget https://sourceforge.net/projects/sofia-sip/files/sofia-sip/1.12.11/sofia-sip-1.12.11.tar.gz
tar zxf sofia-sip-1.12.11.tar.gz && cd sofia-sip-1.12.11 && ./configure –prefix=/usr CFLAGS=-fno-aggressive-loop-optimizations && make && make install

#安装usrsctp来支持数据通道
git clone https://github.com/sctplab/usrsctp.git && cd usrsctp && \\
./bootstrap && \\
./configure –prefix=/usr && make && make install

#安装 libwebsocket
# github 下载过慢 已导入到https://gitee.com/ssCheese/libwebsockets.git
git clone https://github.com/warmcat/libwebsockets.git && \\
mkdir libwebsockets/build && cd libwebsockets/build && \\
cmake -DMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. && \\
make && make install

#安装Janus(重新安装需要先make clean 再从sh autogen.sh依次重新执行)
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig

git clone https://github.com/meetecho/janus-gateway.git && \\
cd janus-gateway &&\\
sh autogen.sh && \\
./configure –prefix=/deploy/janus/janus –disable-rabbitmq –disable-docs &&\\
make && make install && make configs

详细的配置可以打开文件/deploy/janus/janus/etc/janus/janus.jcfg按照注释进行配置

# 运行
nohup /deploy/janus/janus/bin/janus >> /deploy/janus/log/janus.log 2>&1 &
#可以通过如下命令查看janus已经起来
netstat -anp | grep janus

# 问题-缺少各种库文件
1、首先打开/etc/ld.so.conf文件
2、加入动态库文件所在的目录:执行vi /etc/ld.so.conf,在"include ld.so.conf.d/*.conf"下方增加"/usr/local/lib"。
3、保存后,在命令行终端执行:
/sbin/ldconfig -v;其作用是将文件/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用,因此当安装完一些库文件,或者修改/etc/ld.so.conf增加了库的新搜索路径,需要运行一下ldconfig,使所有的库文件都被缓存到文件/etc/ld.so.cache中,如果没做,可能会找不到刚安装的库。

# 运行demo 有跨域问题 (在配置文件 /deploy/janus/janus/etc/janus/janus.transport.http.jcfg 增加ipv4支持,配置跨域问题)
cd /deploy/janus/janus/share/janus/demos
python -m SimpleHTTPServer
命令行输出:Serving HTTP on 0.0.0.0 port 8000 …

# 安装janus时configure后REST(HTTP/HTTPS)一直是NO
需要安装libmicrohttpd,yum没有用,到github下载编译(编译必须yum安装过gettext-devel)
git clone
cd libmicrohttpd
./autogen.sh
./configure –prefix=/usr && make && make install

# libmicrohttpd的configure结果:
configure: GNU libmicrohttpd 0.9.69 Configuration Summary:
Target directory: /usr
Cross-compiling: no
Operating System: linux-gnu
Shutdown of listening socket trigger select: yes
Inter-thread comm: eventfd
poll support: yes
epoll support: yes
sendfile used: yes, Linux-style
HTTPS support: no (lacking libgnutls)
Threading lib: posix
Use thread names: yes
Use debug asserts: no
Messages: yes
Gettext: yes
Basic auth.: yes
Digest auth.: yes
HTTP "Upgrade": yes
Postproc: yes
Build docs: yes
Build examples: yes
Test with libcurl: no, many unit tests will not run

configure:
License : LGPL or eCos

yum -y install libcurl-devel 后 (Test with libcurl: yes)

janus安装结果记录

Compiler: gcc
libsrtp version: 2.x
SSL/crypto library: OpenSSL
DTLS set-timeout: not available
Mutex implementation: GMutex (native futex on Linux)
DataChannels support: yes
Recordings post-processor: no
TURN REST API client: no
Doxygen documentation: no
Transports:
REST (HTTP/HTTPS): yes
WebSockets: yes
RabbitMQ: no
MQTT: no
Unix Sockets: yes
Nanomsg: no
Plugins:
Echo Test: yes
Streaming: yes
Video Call: yes
SIP Gateway: yes
NoSIP (RTP Bridge): yes
Audio Bridge: yes
Video Room: yes
Voice Mail: yes
Record&Play: yes
Text Room: yes
Lua Interpreter: no
Duktape Interpreter: no
Event handlers:
Sample event handler: no
WebSocket ev. handler: yes
RabbitMQ event handler:no
MQTT event handler: no
Nanomsg event handler: no
GELF event handler: yes
External loggers:
JSON file logger: no
JavaScript modules: no

Libraries have been installed in:
/deploy/janus/janus/lib/janus/transports

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
– use the `-Wl,-rpath -Wl,LIBDIR' linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf'

tcp 0 0 0.0.0.0:8188 0.0.0.0:* LISTEN 13287/janus
udp 0 0 0.0.0.0:41957 0.0.0.0:* 13287/janus
udp6 0 0 :::53475 :::* 13287/janus
udp6 0 0 :::5002 :::* 13287/janus
udp6 0 0 :::5004 :::* 13287/janus
raw 0 0 0.0.0.0:132 0.0.0.0:* 7 13287/janus
raw6 0 0 :::132 :::* 7 13287/janus
unix 3 [ ] STREAM CONNECTED 32074404 13287/janus
unix 3 [ ] STREAM CONNECTED 32074403 13287/janus

libmicrohttpd HTTPS support: no (lacking libgnutls)

https://blog.csdn.net/tianlanzhu/article/details/103976181
gnutls下载地址ftp://ftp.gnutls.org/gcrypt/gnutls/ 下载gnutls-3.3.29.tar.xz
./configure –prefix=/usr && make && make install
报错:Libnettle 2.7.1 was not found.
安装nettle 2.7.1后:
configure结果如下,但是make失败
configure: summary of build options:

version: 3.3.29 shared 71:3:43
Host/Target system: x86_64-unknown-linux-gnu
Build system: x86_64-unknown-linux-gnu
Install prefix: /usr
Compiler: gcc
CFlags: -g -O2
Library types: Shared=yes, Static=no
Local libopts: yes
Local libtasn1: yes
Use nettle-mini: no
nettle-version: 2.7.1

configure: External hardware support:

/dev/crypto: no
Hardware accel: x86-64
Padlock accel: yes
PKCS#11 support: no
TPM support: no

configure:
TPM library: /usr/lib64/libtspi.so.1

configure: Optional features:
(note that included applications might not compile properly
if features are disabled)

DTLS-SRTP support: yes
ALPN support: yes
OCSP support: yes
Ses. ticket support: yes
OpenPGP support: yes
SRP support: yes
PSK support: yes
DHE support: yes
ECDHE support: yes
RSA-EXPORT support: yes
Anon auth support: yes
Heartbeat support: yes
Unicode support: yes
Self checks: no
Non-SuiteB curves: yes
FIPS140 mode: no

configure: Optional applications:

crywrap app: no

configure: Optional libraries:

Guile wrappers: no
C++ library: yes
DANE library: no
OpenSSL compat: yes

configure: System files:

Trust store pkcs11:
Trust store dir:
Trust store file: /etc/pki/tls/cert.pem
Blacklist file:
CRL file:
Priority file: /etc/gnutls/default-priorities
DNSSEC root key file: /etc/unbound/root.key

configure: WARNING:
***
*** The DNSSEC root key file in /etc/unbound/root.key was not found.
*** This file is needed for the verification of DNSSEC responses.
*** Use the command: unbound-anchor -a "/etc/unbound/root.key"
*** to generate or update it.
***

nettle 下载地址:https://ftp.gnu.org/gnu/nettle/ 下载nettle-2.7.1.tar.gz
./configure –prefix=/usr && make && make install 成功

最后 yum install gnutls-devel 成功 ?? 不用安装上面这些步骤,重新configure libmicrohttpd 后,https → yes

然而janus https还是没启动成功
官方https://janus.conf.meetecho.com/docs/deploy 建议反向代理:
server {
listen 8000 ssl;
server_name janus.efarm360.com;
ssl_certificate /deploy/janus/cert/4418498_janus.efarm360.com.pem;
ssl_certificate_key /deploy/janus/cert/4418498_janus.efarm360.com.key;
charset utf-8;
root /deploy/janus/janus/share/janus/demos;
index index.php index.html index.htm;
location /backjanus {
proxy_pass http://36.112.137.65:8288/janus;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

yum -y install libcurl-devel

安装CoTurn服务
https://www.gongzi.org/janus-webrtc-install.html
在安装CoTurn服务执行./configure时,碰到了一个报错,这里提前说明,先做解决。

Libevent2 development is not installed properly
ERROR: Libevent2 development libraries are not installed properly in required location.
ERROR: may be you have just too old libevent tool – then you have to upgrade it.
See the INSTALL file.
Abort.
解决办法如下:

sudo yum install libevent libevent-devel openssl openssl-libs -y
然后:

cd ~
wget https://sourceforge.net/projects/levent/files/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz/download
mv download libevent-2.0.22-stable.tar.gz
tar zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure
make
sudo make install

然后开始正常安装CoTurn服务。

cd ~
mkdir /root/webrtc
cd /root/webrtc
wget http://coturn.net/turnserver/v4.5.1.3/turnserver-4.5.1.3.tar.gz
tar zxvf turnserver-4.5.1.3.tar.gz
cd /root/webrtc/turnserver-4.5.1.3
./configure
make
make install

configure结果:

Library option -lsqlite3 cannot be used
SQLite3 development library cannot be found.

SQLite DEVELOPMENT LIBRARY (libsqlite3) AND/OR HEADER (sqlite3.h)
ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT SQLITE SUPPORT.

POSTGRESQL DEVELOPMENT LIBRARY (libpq.a) AND/OR HEADER (libpq-fe.h)
ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT POSTGRESQL DATABASE SUPPORT.

MYSQL DEVELOPMENT LIBRARY (libmysqlclient) AND/OR HEADER (mysql.h)
ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MYSQL DATABASE SUPPORT.

MONGODB DEVELOPMENT LIBRARIES (libmongoc-1.0 and libbson-1.0) AND/OR HEADER (mongoc.h)
ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MONGODB SUPPORT.

HIREDIS DEVELOPMENT LIBRARY (libhiredis.*) AND/OR HEADERS (hiredis/*.h)
ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT REDIS SUPPORT.

make install 结果:

1) If your system supports automatic start-up system daemon services,
then to enable the turnserver as a system service that is automatically
started, you have to:

a) Create and edit /etc/turnserver.conf or
/usr/local/etc/turnserver.conf .
Use /usr/local/etc/turnserver.conf.default as an example.

b) For user accounts settings: set up SQLite or PostgreSQL or
MySQL or MongoDB or Redis database for user accounts.
Use /usr/local/share/turnserver/schema.sql as SQL database schema,
or use /usr/local/share/turnserver/schema.userdb.redis as Redis
database schema description and/or
/usr/local/share/turnserver/schema.stats.redis
as Redis status & statistics database schema description.

If you are using SQLite, the default database location is in
/var/db/turndb or in /usr/local/var/db/turndb or in /var/lib/turn/turndb.

c) add whatever is necessary to enable start-up daemon for the
/usr/local/bin/turnserver.

2) If you do not want the turnserver to be a system service,
then you can start/stop it "manually", using the "turnserver"
executable with appropriate options (see the documentation).

3) To create database schema, use schema in file
/usr/local/share/turnserver/schema.sql.

4) For additional information, run:

$ man turnserver
$ man turnadmin
$ man turnutils

服务配置
此处主要是涉及到turn服务及Janus服务的配置项目。

CoTurn服务的配置
vi /usr/local/etc/turnserver.conf
打开后在文件中添加以下配置(#的注释要单独一行):

relay-device=eth0
#LocalIP
listening-ip=192.168.0.94
# 应该需要防火墙开放端口
listening-port=3478
tls-listening-port=5349
#LocalIP
relay-ip=192.168.0.94
#NetIP
external-ip=36.112.137.65
relay-threads=50
# long-term验证机制,webrtc 通过 TURN中继使用的验证方式,默认关闭即不需要认证机制。
lt-cred-mech
cert=/deploy/janus/cert/4418498_janus.efarm360.com.pem
pkey=/deploy/janus/cert/4418498_janus.efarm360.com.key
#配置一个用户名密码
user=user:password123
# UDP中继端口范围,用于UDP转发,注意安全组放通
min-port=3480
max-port=3500
#所用的域名
cli-password=password123
realm=janus.efarm360.com

启动Turn服务

/usr/local/bin/turnserver -c /usr/local/etc/turnserver.conf -o

janus.jcnf

nat中设置
stun_server = "janus.efarm360.com"
stun_port = 3478
nice_debug = false
###要配置nat_1_1_mapping,且为当前服务器的公共ip地址.
nat_1_1_mapping = "36.112.137.65"

demo 代码中需要,添加iceServer,

查找替换:

server: server,
替换为:

server: server,iceServers: [{urls: "turn:janus.efarm360.com:3478", username: "user", credential: "password123"}],

使用 https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ 测试

https://blog.csdn.net/Linuxhus/article/details/108266001

Medooze

使用websocket做视频直播

https://cloud.tencent.com/developer/article/1635563

ffmpeg

https://blog.csdn.net/leixiaohua1020/article/details/15811977
centos 安装ffmpeg
https://www.cnblogs.com/wintercloud/p/11162962.html
下载地址:https://johnvansickle.com/ffmpeg/release-source/

ffmpeg -re -stream_loop -1 -i ./01.mp4 -s 426×240 -c:v libx264 -profile:v baseline -b:v 1M -r 24 -g 60 -an -f rtp rtp://127.0.0.1:5004 >test.sdp

ffplay -protocol_whitelist "file,http,https,rtp,udp,tcp,tls" test.sdp

https://github.com/leixiaohua1020

https://me.csdn.net/leixiaohua1020
https://my.oschina.net/leixiaohua1020

hls

推流:
ffmpeg -re -i 01.mp4 -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280×720 -q 10 rtmp://ip:8084/live/test

播放地址:
http://ip:8083/hls/test.m3u8

GB28181

无人机硬盘录像机配置:

SIP服务器ID: 33030200002000000001
SIP服务器域: 3303020000
SIP服务器地址: 12x.22x.xxx.16x
SIP服务器端口:5160
SIP用户名: 33030100121180000677
SIP用户认证ID: 33030100121180000677
密码:************
视频通道编码ID: 33030100121320000677—33030100121320000680,共4个摄像头

ffmpeg推rtp流

ffmpeg -re -i 01.mp4 -vcodec h264 -acodec aac -f rtp_mpegts rtp://125.124.87.51:30000

wvppro+zlmediakit
https://github.com/xia-chu/ZLMediaKit/blob/master/docker/ubuntu18.04/Dockerfile.runtime
https://github.com/648540858/wvp-GB28181-pro/wiki/%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3
https://github.com/swwheihei/wvp-GB28181/wiki/API-%E6%8E%A5%E5%8F%A3
https://notemi.cn/wvp—zlmedia-kit—mediaserverui-to-realize-streaming-playback-and-recording-of-camera-gb28181.html

# docker
docker run -id -p 1935:1935 -p 8888:80 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 30000-30500:30000-30500 -p 30000-30500:30000-30500/udp panjjo/zlmediakit
# 运行wvp-pro
nohup java -jar /data/sip/wvp-2.5.8.jar –media.ip=125.124.104.84 –media.port=8888 &

待整理

http://125.124.104.84:18080/api/devices?page=1&count=1
nohup java -jar /data/sip/wvp-2.5.8.jar –sip.ip=125.124.104.84 &
nohup java -jar /data/sip/wvp-2.5.8.jar &
nohup java -jar /data/sip/wvp-2.5.8.jar –media.ip=125.124.104.84 –media.port=8888 &
nohup java -jar /data/sip/wvp-2.5.8.jar –media.hookIp=125.124.104.84 –media.streamNoneReaderDelayMS=-1 &

docker run -id -p 1935:1935 -p 8888:80 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 30000-30500:30000-30500 -p 30000-30500:30000-30500/udp panjjo/zlmediakit

docker run -p 1935:1935 -p 1985:1985 -p 8888:8080 -p 5060:5060 -p 5060:5060/udp -p 8000:8000 -p 8000:8000/udp -p 9000:9000 -p 9000:9000/udp
-v /data/sip/push.gb28281.conf:/usr/local/srs/conf/srs.conf
-v /data/logs/srs.log:/usr/local/srs/objs/srs.log
ossrs/srs:3

http://125.124.104.84:1985/api/v1/gb28181?action=sip_query_session
./objs/srs -c /data/sip/push.gb28281.conf
rtmp://125.124.104.84:1935/live/33048230001320044110
rtmp://125.124.104.84:1935/live/33048200002000336336@33048230001320044110

http://125.124.87.51:8085/index/api/getRtpInfo?secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc&port=30000&stream_id=gb_play_33030100121180000677_33030100121320000677


rtmp://125.124.104.84:1935/rtp/gb_play_33030100121180000677_33030100121320000677

rtmp://125.124.104.84:1935/rtp/gb_play_33048200002000336336_33048230001320044110

rtmp://125.124.104.84:1935/rtp/gb_play_33030100121180000677_33030100121320000677
rtmp://125.124.104.84:1935/rtp/gb_play_33030100121180000677_33030100121320000678

33030100121180000677

2020-12-24 01:16:29.251 W MediaServer[1] RtpSelector.cpp:109 onManager | RtpProcess timeout:gb_play_33030100121180000677_33030100121320000677
2020-12-24 01:16:29.251 I MediaServer[1] TcpServer.h:143 ~TcpServer | close tcp server 0.0.0.0:30000
2020-12-24 01:16:29.251 W MediaServer[1] RtpProcess.cpp:54 ~RtpProcess | gb_play_33030100121180000677_33030100121320000677(0.0.0.0:0) RTP推流器(defaultVhost/rtp/gb_play_33030100121180000677_33030100121320000677)断开,耗时(s):0

request:

POST /index/api/openRtpServer

content:

secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc&port=10008&stream_id=gb_play_34020000001110000001_34020000001320000058&enable_tcp=1

response:

{
“code” : 0,
“port” : 10008
}

https://github.com/xia-chu/ZLMediaKit/blob/master/docker/ubuntu18.04/Dockerfile.runtime
https://github.com/648540858/wvp-GB28181-pro/wiki/%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3
https://github.com/swwheihei/wvp-GB28181/wiki/API-%E6%8E%A5%E5%8F%A3
https://notemi.cn/wvp—zlmedia-kit—mediaserverui-to-realize-streaming-playback-and-recording-of-camera-gb28181.html

http://125.124.104.84:9001/static/index.html

username: admin

username:

# [可选] 密码, 默认为admin

password:

password: 21232f297a57a5a743894a0e4a801fc3

国标协议级联

开源流媒体服务:https://github.com/ossrs/srs/
https://github.com/GB28181/GB28181.Solution
https://github.com/xialixin/srs_code_note/blob/master/doc/srs_gb28181.md
http://125.124.104.84:8100/srs_gb28181.html

赞(0)
未经允许不得转载:171主机测评 » 开源流媒体相关分享
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址