Ubuntu下使用Live555搭建流媒体服务器
程序员文章站
2022-07-14 20:31:49
...
一、下载安装
wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz tar -xzvf live555-latest.tar.gz cd live ./genMakefiles linux-64bit make
二、运行
cd mediaServer./live555MediaServer
可以看到,提示中有这么一句话:rtsp://192.168.10.201/<filename>。说明可以用rtsp协议来访问文件,试了一下,rtsp可以访问,http不行。
三、测试
这里我在当前目录下创建一个video的文件夹,在文件夹里上传一个视频文件cat.mkv
客户端使用VLC,选择打开网络串流,在URL栏中填写:
rtsp://192.168.10.201/video/cat.mkv
点击播放后,出现了视频画面
网上有人说http也可以,然后我试了一下http地址:
报了以下错误
不确定是否是我的Live555的版本问题。
四、RTSP协议
测试了连接成功后播放、暂停/取消暂停、跳转到指定时间播放、停止播放,这四种情况,抓取数据包,抓包结果如下:
连接成功后播放:
OPTIONS rtsp://192.168.10.201:554/video/cat.mkv RTSP/1.0
CSeq: 2
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
RTSP/1.0 200 OK
CSeq: 2
Date: Fri, Nov 15 2019 14:12:17 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
DESCRIBE rtsp://192.168.10.201:554/video/cat.mkv RTSP/1.0
CSeq: 3
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Accept: application/sdp
RTSP/1.0 200 OK
CSeq: 3
Date: Fri, Nov 15 2019 14:12:17 GMT
Content-Base: rtsp://192.168.10.201/video/cat.mkv/
Content-Type: application/sdp
Content-Length: 821
v=0
o=- 1573827137007045 1 IN IP4 192.168.10.201
s=Matroska video+audio+(optional)subtitles, streamed by the LIVE555 Media Server
i=video/cat.mkv
t=0 0
a=tool:LIVE555 Streaming Media v2019.12.10
a=type:broadcast
a=control:*
a=range:npt=0-6278.580
a=x-qt-text-nam:Matroska video+audio+(optional)subtitles, streamed by the LIVE555 Media Server
a=x-qt-text-inf:video/cat.mkv
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=640029;sprop-parameter-sets=Z2QAKazIUB4AiflwEQAAAwABAAADADCPGDGW,aOk40siw
a=control:track1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:96
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=119056E500
a=control:track2
SETUP rtsp://192.168.10.201/video/cat.mkv/track1 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Transport: RTP/AVP;unicast;client_port=56710-56711
RTSP/1.0 200 OK
CSeq: 4
Date: Fri, Nov 15 2019 14:12:17 GMT
Transport: RTP/AVP;unicast;destination=192.168.10.200;source=192.168.10.201;client_port=56710-56711;server_port=6970-6971
Session: 87C03A20;timeout=65
SETUP rtsp://192.168.10.201/video/cat.mkv/track2 RTSP/1.0
CSeq: 5
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Transport: RTP/AVP;unicast;client_port=56712-56713
Session: 87C03A20
RTSP/1.0 200 OK
CSeq: 5
Date: Fri, Nov 15 2019 14:12:17 GMT
Transport: RTP/AVP;unicast;destination=192.168.10.200;source=192.168.10.201;client_port=56712-56713;server_port=6972-6973
Session: 87C03A20;timeout=65
PLAY rtsp://192.168.10.201/video/cat.mkv/ RTSP/1.0
CSeq: 6
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Session: 87C03A20
Range: npt=0.000-
RTSP/1.0 200 OK
CSeq: 6
Date: Fri, Nov 15 2019 14:12:17 GMT
Range: npt=0.000-
Session: 87C03A20
RTP-Info: url=rtsp://192.168.10.201/video/cat.mkv/track1;seq=56914;rtptime=392969077,url=rtsp://192.168.10.201/video/cat.mkv/track2;seq=44478;rtptime=2101804251
暂停/取消暂停:
PAUSE rtsp://192.168.10.201/video/cat.mkv/ RTSP/1.0
CSeq: 7
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Session: 87C03A20
RTSP/1.0 200 OK
CSeq: 7
Date: Fri, Nov 15 2019 14:12:59 GMT
Session: 87C03A20
PLAY rtsp://192.168.10.201/video/cat.mkv/ RTSP/1.0
CSeq: 8
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Session: 87C03A20
RTSP/1.0 200 OK
CSeq: 8
Date: Fri, Nov 15 2019 14:13:04 GMT
Range: npt=42.923-
Session: 87C03A20
RTP-Info: url=rtsp://192.168.10.201/video/cat.mkv/track1;seq=64023;rtptime=397245354,url=rtsp://192.168.10.201/video/cat.mkv/track2;seq=46492;rtptime=2104084526
跳转到指定时间播放:
PAUSE rtsp://192.168.10.201/video/cat.mkv/ RTSP/1.0
CSeq: 10
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Session: 87C03A20
RTSP/1.0 200 OK
CSeq: 10
Date: Fri, Nov 15 2019 14:13:49 GMT
Session: 87C03A20
PLAY rtsp://192.168.10.201/video/cat.mkv/ RTSP/1.0
CSeq: 11
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Session: 87C03A20
Range: npt=2048.701-
RTSP/1.0 200 OK
CSeq: 11
Date: Fri, Nov 15 2019 14:13:49 GMT
Range: npt=2039.875-
Session: 87C03A20
RTP-Info: url=rtsp://192.168.10.201/video/cat.mkv/track1;seq=3332;rtptime=401713377,url=rtsp://192.168.10.201/video/cat.mkv/track2;seq=48598;rtptime=2106472697
停止播放:
TEARDOWN rtsp://192.168.10.201/video/cat.mkv/ RTSP/1.0
CSeq: 13
User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2016.11.28)
Session: 87C03A20
RTSP/1.0 200 OK
CSeq: 13
Date: Fri, Nov 15 2019 14:14:36 GMT
没有做详细的分析,RTSP协议不了解,后续再看看。
上一篇: 搭建QT+ffmpeg+Visual Studio开发环境
下一篇: 音视频基础_2_数字音频简介