定位录像时间的rtsp消息
qq:9611153 微信lgs9611153
时间:2012/03/14
背景原因:
使用rtsp至今依然是重要的媒体播放方式,这里回顾一下,录像定位方法。
定位消息play:
我们使用rtsp的play消息定位录像的位置,例如
PLAY rtsp://192.168.10.108:554/h264/ch1/main/av_stream RTSP/1.0
Authorization: Basic YWRtaW46MTIzNDU=
CSeq: 6
Session: 1528544584
Range: npt=0.0-
x-prebuffer: maxtime=0.0
User-agent: RtspClient
---------
RTSP/1.0 200 OK
CSeq: 6
Session: 1528544584
Range: npt=now-
RTP-Info: url=trackID=1;seq=17915,url=trackID=2;seq=57620
-------------------------------------------------------------------
在describe中查询录像长度和时间
RTSP/1.0 200 OK
Server: DSS/1.0.5 (Build/6; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 3
Last-Modified: Tue, 08 May 2012 08:16:40 GMT
Cache-Control: must-revalidate
Content-length: 396
Date: Thu, 10 May 2012 03:15:59 GMT
Expires: Thu, 10 May 2012 03:15:59 GMT
Content-Type: application/sdp
x-Accept-Retransmit: our-retransmit
x-Accept-Dynamic-Rate: 1
Content-Base: rtsp://192.168.10.35:554/video1/
v=0
o=StreamingServer 3331435948 1116907222000 IN IP4 192.168.10.109
s=h264.mp4
c=IN IP4 0.0.0.0
t=0 0
a=starttime: 20120424181818
a=range:npt=0.00000-698.40000
a=control:*
m=video 0 RTP/AVP 96
a=3GPP-Adaptation-Support:1
a=control:trackID=0
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42801E;sprop-parameter-sets=Njc0MmUwMTRkYTA1ODI1MQ==,NjhjZTMwYTQ4MA==;packetization-mode=1
可以分析出配置。
static const char* sRangeNpt = "a=range:npt=";
static const char* sStartTime = "a=starttime: ";
------------
播放和暂停消息
PLAY rtsp://192.168.10.35:554/video1/ RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 7705749015246682008
Range: npt=0.000-
RTSP/1.0 200 OK
Server: DSS/1.0.5 (Build/6; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 5
Session: 7705749015246682008
Range: npt=0.00000-698.40000
RTP-Info: url=rtsp://192.168.10.35:554/video1/trackID=0;seq=15619;rtptime=1911497317
PAUSE rtsp://192.168.10.35:554/video1/ RTSP/1.0
CSeq: 6
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 7705749015246682008
RTSP/1.0 200 OK
Server: DSS/1.0.5 (Build/6; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 6
Session: 7705749015246682008
PLAY rtsp://192.168.10.35:554/video1/ RTSP/1.0
CSeq: 7
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 7705749015246682008
Range: npt=396.691-
RTSP/1.0 200 OK
Server: DSS/1.0.5 (Build/6; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 7
Session: 7705749015246682008
Range: npt=396.69100-698.40000
RTP-Info: url=rtsp://192.168.10.35:554/video1/trackID=0;seq=17212;rtptime=1912838828
PLAY rtsp://192.168.10.35:554/video1/ RTSP/1.0
CSeq: 6
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 7705749015912989047
Scale: 1.100110
RTSP/1.0 200 OK
Server: DSS/1.0.5 (Build/6; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 6
Session: 7705749015912989047
Speed: 1.10011
Range: npt=22.16000-698.40000
RTP-Info: url=rtsp://192.168.10.35:554/video1/trackID=0;seq=20973;rtptime=1294004159
PLAY rtsp://192.168.10.35:554/video1/ RTSP/1.0
CSeq: 10
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 7705749015912989047
Scale: 0.900090
RTSP/1.0 200 OK
Server: DSS/1.0.5 (Build/6; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 10
Session: 7705749015912989047
Speed: 0.90009
Range: npt=97.16000-698.40000
RTP-Info: url=rtsp://192.168.10.35:554/video1/trackID=0;seq=32044;rtptime=1292160624