rtsp超分推流流程(一)

记录一下rtsp 推流的流程

播放一个RTSP的流需要如下的RTSP请求命令:

OPTIONS -> DESCRIBE -> SETUP -> PLAY 然后就是接收RTP包、播放了

抓包分析出来,推流的RTSP请求命令如下:

OPTIONS -> ANNOUNCE -> SETUP -> RECORD

可以使用ffmpeg命令来模拟一路视频和音频推流,

ffmpeg -re -stream_loop -1 -i abc.mkv -rtsp_transport tcp -c copy -f rtsp rtsp://127.0.0.1:8554/stream

udp 推流

OPTIONS rtsp://192.168.0.135:8554/stream RTSP/1.0
CSeq: 1
User-Agent: Lavf60.16.100

RTSP/1.0 200 OK

CSeq: 1

Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN

Server: gortsplib

ANNOUNCE rtsp://192.168.0.135:8554/stream RTSP/1.0
Content-Type: application/sdp
CSeq: 2
User-Agent: Lavf60.16.100
Content-Length: 500

**v=0

o=- 0 0 IN IP4 127.0.0.1

s=No Name

c=IN IP4 192.168.0.135

t=0 0

a=tool:libavformat 60.16.100

m=video 0 RTP/AVP 96

a=rtpmap:96 H264/90000

a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAH6wspQFAFuwFqAgICgAAB9AAAdTBwAAATEsAACYlrd5cFA==,aOuPLA==; profile-level-id=64001F

a=control:streamid=0

m=audio 0 RTP/AVP 97

a=rtpmap:97 MPEG4-GENERIC/48000/2

a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=119056E500

a=control:streamid=1

**

RTSP/1.0 200 OK

CSeq: 2

Server: qbserver

SETUP rtsp://192.168.0.135:8554/stream/streamid=0 RTSP/1.0

Transport: RTP/AVP/UDP;unicast;client_port=17130-17131;mode=record

CSeq: 3

User-Agent: Lavf60.16.100

RTSP/1.0 200 OK

CSeq: 3

Server: gortsplib

Session: 04528041c4c342a7a3d1e0bbeb28b8e1

Transport: RTP/AVP;unicast;client_port=17130-17131;server_port=8000-8001

SETUP rtsp://192.168.0.135:8554/stream/streamid=1 RTSP/1.0

Transport: RTP/AVP/UDP;unicast;client_port=17132-17133;mode=record

CSeq: 4

User-Agent: Lavf60.16.100

Session: 04528041c4c342a7a3d1e0bbeb28b8e1

RTSP/1.0 200 OK

CSeq: 4

Server: gortsplib

Session: 04528041c4c342a7a3d1e0bbeb28b8e1

Transport: RTP/AVP;unicast;client_port=17132-17133;server_port=8000-8001

RECORD rtsp://192.168.0.135:8554/stream RTSP/1.0

Range: npt=0.000-

CSeq: 5

User-Agent: Lavf60.16.100

Session: 04528041c4c342a7a3d1e0bbeb28b8e1

RTSP/1.0 200 OK

CSeq: 5

Server: gortsplib

Session: 04528041c4c342a7a3d1e0bbeb28b8e1

EASYPUSHER安卓ANDROID手机直播推送之MEDIACODEC 硬编码H264格式

https://www.freesion.com/article/4282847055/

tcp 推流

以下是tcp,重点是tcp,尤其是在需要外网的时候,必须使用tcp来推流,udp方式是通不过的。

OPTIONS rtsp://127.0.0.1:8554/stream RTSP/1.0
CSeq: 1
User-Agent: Lavf60.16.100

RTSP/1.0 200 OK

CSeq: 1

Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN

Server: gortsplib

ANNOUNCE rtsp://127.0.0.1:8554/stream RTSP/1.0
Content-Type: application/sdp
CSeq: 2
User-Agent: Lavf60.16.100
Content-Length: 496
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 60.16.100
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAH6wspQFAFuwFqAgICgAAB9AAAdTBwAAATEsAACYlrd5cFA==,aOuPLA==; profile-level-id=64001F
a=control:streamid=0
m=audio 0 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=119056E500
a=control:streamid=1
RTSP/1.0 200 OK
CSeq: 2
Server: gortsplib

SETUP rtsp://127.0.0.1:8554/stream/streamid=0 RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=0-1;mode=record
CSeq: 3
User-Agent: Lavf60.16.100

RTSP/1.0 200 OK

CSeq: 3

Server: gortsplib

Session: 74c1debd7c2f45da974c4c6fc80d6fc6

Transport: RTP/AVP/TCP;unicast;interleaved=0-1

SETUP rtsp://127.0.0.1:8554/stream/streamid=1 RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=2-3;mode=record
CSeq: 4
User-Agent: Lavf60.16.100
Session: 74c1debd7c2f45da974c4c6fc80d6fc6

RTSP/1.0 200 OK

CSeq: 4

Server: gortsplib

Session: 74c1debd7c2f45da974c4c6fc80d6fc6

Transport: RTP/AVP/TCP;unicast;interleaved=2-3

RECORD rtsp://127.0.0.1:8554/stream RTSP/1.0
Range: npt=0.000-
CSeq: 5
User-Agent: Lavf60.16.100
Session: 74c1debd7c2f45da974c4c6fc80d6fc6

RTSP/1.0 200 OK

CSeq: 5

Server: gortsplib

Session: 74c1debd7c2f45da974c4c6fc80d6fc6

以下是一些可以参考的资料

https://github.com/fyhertz/spydroid-ipcamera

https://github.com/kidloserme

https://github.com/Oo-Dev/OoDroid2

超分媒体服务

下期再讲

相关推荐
karmueo4613 小时前
视频序列和射频信号多模态融合算法Fusion-Vital解读
算法·音视频·多模态
昨日之日200613 小时前
Video Background Remover V3版 - AI视频一键抠像/视频换背景 支持50系显卡 一键整合包下载
人工智能·音视频
xmode1 天前
centos7.9安装ffmpeg6.1和NASM、Yasm、x264、x265、fdk-aac、lame、opus解码器
ffmpeg·centos
站在巨人肩膀上的码农1 天前
全志T507 音频ALSA核心层注册流程分析
驱动开发·音视频·安卓·全志·alsa·声卡
王江奎1 天前
FFmpeg 升级指北
ffmpeg
】余185381628001 天前
碰一碰发视频源码搭建与定制化开发:支持OEM
音视频
张晓~183399481211 天前
数字人分身+矩阵系统聚合+碰一碰发视频: 源码搭建-支持OEM
线性代数·矩阵·音视频
山登绝顶我为峰 3(^v^)32 天前
如何录制带备注的演示文稿(LaTex Beamer + Pympress)
c++·线性代数·算法·计算机·密码学·音视频·latex
雨夜和阳晨2 天前
FFmpeg录制屏幕及声音
ffmpeg
吴声子夜歌2 天前
FFmpeg——基础知识及FFmpeg框架
ffmpeg