相关疑难解决方法(0)

RTSP设置后接收RTP数据包

我正在尝试使用Python从IP摄像机流式传输RTP数据包.

我能够使用RTSP协议发送describe,setup和play命令,但是,我无法使用RTP开始流式传输实际的视频流.

这是代码:

import socket 

def printrec(recst):
  recs=recst.split('\r\n')
  for rec in recs:
    print rec

dest="DESCRIBE rtsp://admin:12345@192.168.1.74 RTSP/1.0\r\nCSeq: 2\r\nUser-Agent: python\r\nAccept: application/sdp\r\n\r\n"

setu="SETUP rtsp://admin:12345@192.168.1.74/trackID=1 RTSP/1.0\r\nCSeq: 3\r\nUser-Agent: python\r\nTransport: RTP/AVP;unicast;client_port=60784-60785\r\n\r\n"

play="PLAY rtsp://admin:12345@192.168.1.74/ RTSP/1.0\r\nCSeq: 5\r\nUser-Agent: python\r\nSession: SESID\r\nRange: npt=0.000-\r\n\r\n"

# .. here SESID will be substituted with the session id that SETUP returns us ..

ip="192.168.1.74"
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip,554))

s.send(dest)
recst=s.recv(4096)
printrec(recst)

# etc. then the same for the strins "setu" and "play"

....
Run Code Online (Sandbox Code Playgroud)

安装程序回复我:

RTSP/1.0 200 OK
CSeq: 3
Session:       1117448817;timeout=60
Transport: RTP/AVP;unicast;client_port=60784-60785;server_port=8214-8215;ssrc=40d35c30;mode="play"
Date:  Mon, …
Run Code Online (Sandbox Code Playgroud)

python sockets udp rtp rtsp

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

rtp ×1

rtsp ×1

sockets ×1

udp ×1