RTMP 是 Real Time Messaging Protocol(实时消息传输协议)的首字母缩写。它是由 Adobe 公司提出的一种应用层的协议,用来解决多媒体数据传输流的多路复用(Multiplexing)和分包(packetizing)的问题。

该协议基于 TCP,是一个协议族,包括 RTMP 基本协议及 RTMPT/RTMPS/RTMPE 等多种变种。

RTMP 是一种设计用来进行实时数据通信的网络协议,主要用来在 Flash/AIR 平台和支持 RTMP 协议的流媒体或交互服务器之间进行音视频和数据通信。

协议介绍

RTMP 协议规定,播放一个流媒体有两个前提步骤:第一步,建立一个网络连接(NetConnection);第二步,建立一个网络流(NetStream)。

其中,网络连接代表服务器端应用程序和客户端之间基础的连通关系。网络流代表了发送多媒体数据的通道。服务器和客户端之间只能建立一个网络连接,但是基于该连接可以创建很多网络流。他们的关系如图所示:

播放一个 RTMP 协议的流媒体需要经过以下几个步骤:握手,建立连接,建立流,播放,四个步骤流程如下:

            +----------+                     +----------+|  Client  |   TCP/IP Network    |  Server  |+----------+                     +----------+
--------+---|                     |                     ||Uninitialized            |            Uninitialized|   |----------C0-------->|                     ||   |                     |---------C0--------->||   |----------C1-------->|                     ||   |                     |<--------S0----------||Version sent             |<--------S1----------|
Hand-   |   |<---------S0---------|                     |
shake   |   |<---------S1---------|             Version sent|   |                     |---------C1--------->||   |----------C2-------->|                     ||   |                     |<--------S2----------||Ack Sent                 |                Ack Sent|   |<---------S2---------|                     ||   |                     |---------C2--------->||Handshake Done           |           Handshake Done
--------+---|                                           ||                                           |
--------+---|---------- Command Message(connect) ------>||   |                                           ||   |<------ Window Acknowledgement Size -------||   |                                           ||   |<---------- Set Peer Bandwidth ------------||   |                                           |
Appli-  |   |------- Window Acknowledgement Size ------>|
cation  |   |                                           |
Connect |   |<---- User Control Message(StreamBegin) ---||   |                                           ||   |<----------- Command Message --------------||   |       (_result- connect response)         |
--------+---|                                           ||                                           |
--------+---|------ Command Message(createStream) ----->|
Create  |   |                                           |
Stream  |   |<----------- Command Message --------------|
--------+---|      (_result- createStream response)     ||                                           |
--------+---|--------- Command Message (play) --------->||   |                                           ||   |<-------------- SetChunkSize --------------||   |                                           ||   |<---- User Control (StreamIsRecorded) -----||   |                                           ||   |<------- UserControl (StreamBegin) --------||   |                                           |
Play    |   |<-- Command Message(onStatus-play reset) --||   |                                           ||   |<-- Command Message(onStatus-play start) --||   |                                           ||   |<------------- Audio Message --------------||   |                                           ||   |<------------- Video Message --------------||   |                     |                     ||Keep receiving audio and video stream till finishes

握手(HandShake)

握手交互流程

一个 RTMP 连接以握手开始,双方分别发送大小固定的三个数据块:

  1. 握手开始于客户端发送 C0、C1 块。服务器收到 C0 或 C1 后发送 S0 和 S1。

  2. 当客户端收齐 S0 和 S1 后,开始发送 C2。当服务器收齐 C0 和 C1 后,开始发送 S2。

  3. 当客户端和服务器分别收到 S2 和 C2 后,握手完成。

                 +----------+                     +----------+|  Client  |   TCP/IP Network    |  Server  |+----------+                     +----------+--------+---|                     |                     ||Uninitialized            |            Uninitialized|   |----------C0-------->|                     ||   |                     |---------C0--------->||   |----------C1-------->|                     ||   |                     |<--------S0----------||Version sent             |<--------S1----------|Hand-   |   |<---------S0---------|                     |shake   |   |<---------S1---------|             Version sent|   |                     |---------C1--------->||   |----------C2-------->|                     ||   |                     |<--------S2----------||Ack Sent                 |                Ack Sent|   |<---------S2---------|                     ||   |                     |---------C2--------->||Handshake Done           |           Handshake Done--------+---|                                           |Pictorial Representation of Handshake

简化的握手交互流程

而在实际应用中,通常使用三次握手来简化以上握手流程:

Client ---- C0&C1 ----> ServerClient <---- S0&S1&S2 ---- ServerClient ---- C2 ----> Server

握手交互抓包

【学习地址】:FFmpeg/WebRTC/RTMP/NDK/Android音视频流媒体高级开发
【文章福利】:免费领取更多音视频学习资料包、大厂面试题、技术视频和学习路线图,资料包括(C/C++,Linux,FFmpeg webRTC rtmp hls rtsp ffplay srs 等等)有需要的可以点击1079654574加群领取哦~

通过 Wirshark 抓包,得到以下数据包:

  1. Client ---- C0&C1 ----> Server

    0000   03 00 00 00 00 09 00 7c 02 f7 78 55 1e ce ab 8e   .......|..xU....0010   1e 36 2f 07 c5 86 8a 70 b2 66 d4 02 20 e5 08 61   .6/....p.f.. ..a····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················05f0   c4 10 96 07 08 84 39 34 53 ce 50 96 94 af be ab   ......94S.P.....0600   e0                                                .-------------------------------------------------------------------------Protocol version: 03Handshake C1: 0000000009007c02f778551eceab8e1e362f07c5868a70b2…
  2. Client <---- S0&S1&S2 ---- Server

    0000   03 06 a7 7f 3b 0d 0e 0a 0d 8b 4c 51 8d d0 a9 c7   ....;.....LQ....0010   21 e8 6a 5b b0 4a 9d 74 91 0f 30 03 fa bc 77 6e   !.j[.J.t..0...wn····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················0600   2d a1 d7 ca 81 18 80 02 9a d4 94 92 ab 14 ea 8a   -...............····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················0bf0   96 4b 7e 0c f1 27 fb fd 52 02 19 5d d7 73 57 47   .K~..'..R..].sWG0c00   f0                                                .-------------------------------------------------------------------------Protocol version: 03Handshake S1: 06a77f3b0d0e0a0d8b4c518dd0a9c721e86a5bb04a9d7491…Handshake S2: a1d7ca811880029ad49492ab14ea8a119cd415aa26c62ee4…
  3. Client ---- C2 ----> Server

    0000   e2 5c 15 c2 2c af 72 d0 98 6f bd 3e da 0d 71 51   .\..,.r..o.>..qQ····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················05f0   94 e0 bc b0 94 31 f4 20 d6 e7 d3 03 6d 2c 71 77   .....1. ....m,qw-------------------------------------------------------------------------Handshake C2: e25c15c22caf72d0986fbd3eda0d7151973e19083e0abbef…

握手报文分析

C0 与 S0

    C0 与 S0
+-+-+-+-+-+-+-+-+
|    version    |
+-+-+-+-+-+-+-+-+
  • C0:客户端发送其所支持的 RTMP 版本号:3~31。一般都是写 3

  • S1:服务端返回其所支持的版本号。如果没有客户端的版本号,默认返回 3

C1 与 S1

       C1 与 S1
+-+-+-+-+-+-+-+-+-+-+
|   time (4 bytes)  |
+-+-+-+-+-+-+-+-+-+-+
|   zero (4 bytes)  |
+-+-+-+-+-+-+-+-+-+-+
|   random bytes    |
+-+-+-+-+-+-+-+-+-+-+
|random bytes(cont) |
|       ....        |
+-+-+-+-+-+-+-+-+-+-+
  • C1/S1 长度为 1536B。主要目的是确保握手的唯一性。

  • 格式为 time + zero + random

  • time 发送时间戳,长度 4 byte

  • zero 保留值 0,长度 4 byte

  • random 随机值,长度 1528 byte,保证此次握手的唯一性,确定握手的对象

C2 与 S2

       C2 与 S2
+-+-+-+-+-+-+-+-+-+-+
|   time (4 bytes)  |
+-+-+-+-+-+-+-+-+-+-+
|   time2(4 bytes)  |
+-+-+-+-+-+-+-+-+-+-+
|   random bytes    |
+-+-+-+-+-+-+-+-+-+-+
|random bytes(cont) |
|       ....        |
+-+-+-+-+-+-+-+-+-+-+
  • C2/S2 的长度也是 1536B。相当于就是 S1/C1 的响应值,对应 C1/S1 的 Copy 值,在于字段有点区别

  • time, C2/S2 发送的时间戳,长度 4 byte

  • time2, S1/C1 发送的时间戳,长度 4 byte

  • random,S1/C1 发送的随机数,长度为 1528B

建立网络连接(NetConnection)

建立网络连接交互流程

  1. Client ----> Server : Command Message Connect

  2. Client <---- Server : Window Acknowledgement Size

  3. Client <---- Server : Set Peer Bandwidth

  4. Client ----> Server : Window Acknowledgement Size

  5. Client <---- Server : User Control Message Stream Begin

  6. Client <---- Server : Command Message _result

                 +----------+                     +----------+|  Client  |          |          |  Server  |+----------+          |          +----------+--------+---|---------- Command Message(connect) ------>||   |                                           ||   |<------ Window Acknowledgement Size -------||   |                                           ||   |<---------- Set Peer Bandwidth ------------||   |                                           |Appli-  |   |------- Window Acknowledgement Size ------>|cation  |   |                                           |Connect |   |<---- User Control Message(StreamBegin) ---||   |                                           ||   |<----------- Command Message --------------||   |       (_result- connect response)         |--------+---|                                           |Message flow in the connect command

建立网络连接抓包

  1. Client ----> Server : AMF0 Command connect()

    0000   03 00 00 00 00 00 cc 14 00 00 00 00 02 00 07 63   ...............c0010   6f 6e 6e 65 63 74 00 3f f0 00 00 00 00 00 00 03   onnect.?........0020   00 03 61 70 70 02 00 06 6d 79 6c 69 76 65 00 08   ..app...mylive..0030   66 6c 61 73 68 56 65 72 02 00 0d 4c 4e 58 20 39   flashVer...LNX 90040   2c 30 2c 31 32 34 2c 32 00 05 74 63 55 72 6c 02   ,0,124,2..tcUrl.0050   00 20 72 74 6d 70 3a 2f 2f 36 32 2e 32 33 34 2e   . rtmp://62.234.0060   31 31 31 2e 31 33 3a 31 39 33 35 2f 6d 79 6c 69   111.13:1935/myli0070   76 65 00 04 66 70 61 64 01 00 00 0c 63 61 70 61   ve..fpad....capa0080   62 69 6c 69 74 69 65 73 00 40 2e 00 00 00 00 00   bilities.@......0090   00 00 0b 61 75 64 69 6f 43 6f 64 65 63 73 00 40   ...audioCodecs.@00a0   af ce 00 00 00 00 00 00 0b 76 69 64 65 6f 43 6f   .........videoCo00b0   64 65 63 73 00 40 6f 80 00 00 00 00 00 00 0d 76   decs.@o........v00c0   69 64 65 6f 46 75 6e 63 74 69 6f 6e 00 3f f0 00   ideoFunction.?..00d0   00 00 00 00 00 00 00 09                           ........-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command connect('mylive'))Response to this call in frame: 20RTMP Header00.. .... = Format: 0..00 0011 = Chunk Stream ID: 3Timestamp: 0Body size: 204Type ID: AMF0 Command (0x14)Stream ID: 0RTMP BodyString 'connect'Number 1Object (8 items)AMF0 type: Object (0x03)Property 'app' String 'mylive'Property 'flashVer' String 'LNX 9,0,124,2'Property 'tcUrl' String 'rtmp://62.234.111.13:1935/mylive'Property 'fpad' Boolean falseProperty 'capabilities' Number 15Property 'audioCodecs' Number 4071Property 'videoCodecs' Number 252Property 'videoFunction' Number 1End Of Object Marker
  2. Server ----> Client : Window Acknowledgement Size

     0000   02 00 00 00 00 00 04 05 00 00 00 00 00 4c 4b 40   .............LK@-------------------------------------------------------------------------Real Time Messaging Protocol (Window Acknowledgement Size 5000000)RTMP Header00.. .... = Format: 0..00 0010 = Chunk Stream ID: 2Timestamp: 0Body size: 4Type ID: Window Acknowledgement Size (0x05)Stream ID: 0RTMP BodyWindow acknowledgement size: 5000000
  3. Server ----> Client : Set Peer Bandwidth

    0000   02 00 00 00 00 00 05 06 00 00 00 00 00 4c 4b 40   .............LK@0010   02                                                .-------------------------------------------------------------------------Real Time Messaging Protocol (Set Peer Bandwidth 5000000,Dynamic)RTMP Header00.. .... = Format: 0..00 0010 = Chunk Stream ID: 2Timestamp: 0Body size: 5Type ID: Set Peer Bandwidth (0x06)Stream ID: 0RTMP BodyWindow acknowledgement size: 5000000Limit type: Dynamic (2)
  4. Server ----> Client : Set Chunk Size

    0000   02 00 00 00 00 00 04 01 00 00 00 00 00 00 10 00   ................-------------------------------------------------------------------------Real Time Messaging Protocol (Set Chunk Size 4096)RTMP Header00.. .... = Format: 0..00 0010 = Chunk Stream ID: 2Timestamp: 0Body size: 4Type ID: Set Chunk Size (0x01)Stream ID: 0RTMP BodyChunk size: 4096
  5. Server ----> Client : AMF0 Command _result

    0000   03 00 00 00 00 00 be 14 00 00 00 00 02 00 07 5f   ..............._0010   72 65 73 75 6c 74 00 3f f0 00 00 00 00 00 00 03   result.?........0020   00 06 66 6d 73 56 65 72 02 00 0d 46 4d 53 2f 33   ..fmsVer...FMS/30030   2c 30 2c 31 2c 31 32 33 00 0c 63 61 70 61 62 69   ,0,1,123..capabi0040   6c 69 74 69 65 73 00 40 3f 00 00 00 00 00 00 00   lities.@?.......0050   00 09 03 00 05 6c 65 76 65 6c 02 00 06 73 74 61   .....level...sta0060   74 75 73 00 04 63 6f 64 65 02 00 1d 4e 65 74 43   tus..code...NetC0070   6f 6e 6e 65 63 74 69 6f 6e 2e 43 6f 6e 6e 65 63   onnection.Connec0080   74 2e 53 75 63 63 65 73 73 00 0b 64 65 73 63 72   t.Success..descr0090   69 70 74 69 6f 6e 02 00 15 43 6f 6e 6e 65 63 74   iption...Connect00a0   69 6f 6e 20 73 75 63 63 65 65 64 65 64 2e 00 0e   ion succeeded...00b0   6f 62 6a 65 63 74 45 6e 63 6f 64 69 6e 67 00 00   objectEncoding..00c0   00 00 00 00 00 00 00 00 00 09                     ..........-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command _result('NetConnection.Connect.Success'))Call for this response in frame: 17RTMP Header00.. .... = Format: 0..00 0011 = Chunk Stream ID: 3Timestamp: 0Body size: 190Type ID: AMF0 Command (0x14)Stream ID: 0RTMP BodyString '_result'Number 1Object (2 items)AMF0 type: Object (0x03)Property 'fmsVer' String 'FMS/3,0,1,123'Property 'capabilities' Number 31End Of Object MarkerObject (4 items)AMF0 type: Object (0x03)Property 'level' String 'status'Property 'code' String 'NetConnection.Connect.Success'Property 'description' String 'Connection succeeded.'Property 'objectEncoding' Number 0End Of Object Marker
  6. Client ----> Server : Window Acknowledgement Size

     0000   02 00 00 00 00 00 04 05 00 00 00 00 00 4c 4b 40   .............LK@-------------------------------------------------------------------------Real Time Messaging Protocol (Window Acknowledgement Size 5000000)RTMP Header00.. .... = Format: 0..00 0010 = Chunk Stream ID: 2Timestamp: 0Body size: 4Type ID: Window Acknowledgement Size (0x05)Stream ID: 0RTMP BodyWindow acknowledgement size: 5000000

建立网络流(NetStream)

  1. 客户端发送命令消息中的 “创建流”(createStream)命令到服务器端。

  2. 服务器端接收到 “创建流” 命令后,发送命令消息中的 “结果”(_result),通知客户端流的状态。

       +----------+                     +----------+|  Client  |          |          |  Server  |+----------+          |          +----------+--------+---|------ Command Message(createStream) ----->|Create  |   |                                           |Stream  |   |<----------- Command Message --------------|--------+---|      (_result- createStream response)     |

建立网络流抓包

  1. Client ----> Server : AMF0 Command createStream()

     0000   43 00 00 00 00 00 19 14 02 00 0c 63 72 65 61 74   C..........creat0010   65 53 74 72 65 61 6d 00 40 00 00 00 00 00 00 00   eStream.@.......0020   05                                                .-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command createStream())Response to this call in frame: 25RTMP Header01.. .... = Format: 1..00 0011 = Chunk Stream ID: 3Timestamp delta: 0Timestamp: 0 (calculated)Body size: 25Type ID: AMF0 Command (0x14)RTMP BodyString 'createStream'Number 2Null
  2. Server ----> Client : AMF0 Command _result

     0000   03 00 00 00 00 00 1d 14 00 00 00 00 02 00 07 5f   ..............._0010   72 65 73 75 6c 74 00 40 00 00 00 00 00 00 00 05   result.@........0020   00 3f f0 00 00 00 00 00 00                        .?.......-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command _result())Call for this response in frame: 23RTMP Header00.. .... = Format: 0..00 0011 = Chunk Stream ID: 3Timestamp: 0Body size: 29Type ID: AMF0 Command (0x14)Stream ID: 0RTMP BodyString '_result'Number 2NullNumber 1

播放(Play)

  1. 客户端发送命令消息中的播放(play)命令到服务器。

  2. 接收到播放命令后,服务器发送设置块大小(ChunkSize)协议消息。

  3. 服务器发送用户控制消息中的 streambegin,告知客户端流 ID。

  4. 播放命令成功的话,服务器发送命令消息中的 “响应状态” NetStream.Play.Start & NetStream.Play.reset,告知客户端播放命令执行成功。

  5. 在此之后服务器发送客户端要播放的音频和视频数据。

             +----------+                     +----------+|  Client  |          |          |  Server  |+----------+          |          +----------+
    --------+---|--------- Command Message (play) --------->| | | | | |<-------------- SetChunkSize --------------| | | | | |<---- User Control (StreamIsRecorded) -----| | | | | |<------- UserControl (StreamBegin) --------| | | | Play | |<-- Command Message(onStatus-play reset) --| | | | | |<-- Command Message(onStatus-play start) --| | | | | |<------------- Audio Message --------------| | | | | |<------------- Video Message --------------| | | | | | Keep receiving audio and video stream till finishes

播放抓包

  1. Client ----> Server : Command getStreamLength()

    0000   08 00 00 00 00 00 1f 14 00 00 00 00 02 00 0f 67   ...............g0010   65 74 53 74 72 65 61 6d 4c 65 6e 67 74 68 00 40   etStreamLength.@0020   08 00 00 00 00 00 00 05 02 00 00                  ...........-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command getStreamLength())RTMP Header00.. .... = Format: 0..00 1000 = Chunk Stream ID: 8Timestamp: 0Body size: 31Type ID: AMF0 Command (0x14)Stream ID: 0RTMP BodyString 'getStreamLength'Number 3NullString ''
  2. Client ----> Server : Command play('')

    0000   08 00 00 00 00 00 1d 14 01 00 00 00 02 00 04 70   ...............p0010   6c 61 79 00 40 10 00 00 00 00 00 00 05 02 00 00   lay.@...........0020   00 c0 9f 40 00 00 00 00 00                        ...@.....-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command play(''))RTMP Header00.. .... = Format: 0..00 1000 = Chunk Stream ID: 8Timestamp: 0Body size: 29Type ID: AMF0 Command (0x14)Stream ID: 1RTMP BodyString 'play'Number 4NullString ''Number -2000
  3. Client ----> Server : User Control Message Set Buffer Length

     0000   42 00 00 01 00 00 0a 04 00 03 00 00 00 01 00 00   B...............0010   0b b8                                             ..-------------------------------------------------------------------------Real Time Messaging Protocol (User Control Message Set Buffer Length 1,3000ms)RTMP Header01.. .... = Format: 1..00 0010 = Chunk Stream ID: 2Timestamp delta: 1Timestamp: 1 (calculated)Body size: 10Type ID: User Control Message (0x04)RTMP BodyEvent type: Set Buffer Length (3)
  4. Server ----> Client : User Control Message Stream Begin

    0000   02 00 00 00 00 00 06 04 00 00 00 00 00 00 00 00   ................0010   00 01                                             ..-------------------------------------------------------------------------Real Time Messaging Protocol (User Control Message Stream Begin 1)RTMP Header00.. .... = Format: 0..00 0010 = Chunk Stream ID: 2Timestamp: 0Body size: 6Type ID: User Control Message (0x04)Stream ID: 0RTMP BodyEvent type: Stream Begin (0)
  5. Server ----> Client : Command onStatus('NetStream.Play.Start')

     0000   05 00 00 00 00 00 60 14 01 00 00 00 02 00 08 6f   ......`........o0010   6e 53 74 61 74 75 73 00 00 00 00 00 00 00 00 00   nStatus.........0020   05 03 00 05 6c 65 76 65 6c 02 00 06 73 74 61 74   ....level...stat0030   75 73 00 04 63 6f 64 65 02 00 14 4e 65 74 53 74   us..code...NetSt0040   72 65 61 6d 2e 50 6c 61 79 2e 53 74 61 72 74 00   ream.Play.Start.0050   0b 64 65 73 63 72 69 70 74 69 6f 6e 02 00 0a 53   .description...S0060   74 61 72 74 20 6c 69 76 65 00 00 09               tart live...-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Command onStatus('NetStream.Play.Start'))RTMP Header00.. .... = Format: 0..00 0101 = Chunk Stream ID: 5Timestamp: 0Body size: 96Type ID: AMF0 Command (0x14)Stream ID: 1RTMP BodyString 'onStatus'Number 0NullObject (3 items)
  6. Server ----> Client : Data |RtmpSampleAccess()

     0000   05 00 00 00 00 00 18 12 01 00 00 00 02 00 11 7c   ...............|0010   52 74 6d 70 53 61 6d 70 6c 65 41 63 63 65 73 73   RtmpSampleAccess0020   01 01 01 01                                       ....-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Data |RtmpSampleAccess())RTMP Header00.. .... = Format: 0..00 0101 = Chunk Stream ID: 5Timestamp: 0Body size: 24Type ID: AMF0 Data (0x12)Stream ID: 1RTMP BodyString '|RtmpSampleAccess'Boolean trueBoolean true
  7. Server ----> Client : Data onMetaData()

     0000   05 00 00 00 00 01 83 12 01 00 00 00 02 00 0a 6f   ...............o0010   6e 4d 65 74 61 44 61 74 61 03 00 06 53 65 72 76   nMetaData...Serv····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················0180   00 00 00 00 00 00 00 00 00 00 00 00 00 00 09      ...............-------------------------------------------------------------------------Real Time Messaging Protocol (AMF0 Data onMetaData())RTMP Header00.. .... = Format: 0..00 0101 = Chunk Stream ID: 5Timestamp: 0Body size: 387Type ID: AMF0 Data (0x12)Stream ID: 1RTMP BodyString 'onMetaData'Object (14 items)AMF0 type: Object (0x03)Property 'Server' String 'NGINX RTMP (github.com/arut/nginx-rtmp-module)'Property 'width' Number 1280Property 'height' Number 720Property 'displayWidth' Number 1280Property 'displayHeight' Number 720Property 'duration' Number 0Property 'framerate' Number 25Property 'fps' Number 25Property 'videodatarate' Number 0Property 'videocodecid' Number 7Property 'audiodatarate' Number 125Property 'audiocodecid' Number 1Property 'profile' String ''Property 'level' String ''End Of Object Marker

数据传输

音频数据

0000   80 fa 5b 46 e3 29 dc a6 32 90 25 1e 08 00 45 00   ..[F.)..2.%...E.
····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················
05e0   aa aa 02 ab 2a 26 a8 20 06 60                     ....*&. .`
-------------------------------------------------------------------------
Real Time Messaging Protocol (Audio Data)RTMP Header00.. .... = Format: 0..00 0110 = Chunk Stream ID: 6Timestamp: 59947Body size: 2054Type ID: Audio Data (0x08)Stream ID: 1RTMP BodyControl: 0x1f (ADPCM 44 kHz 16 bit stereo)0001 .... = Format: ADPCM (1).... 11.. = Sample rate: 44 kHz (3).... ..1. = Sample size: 16 bit (1).... ...1 = Channels: stereo (1)Audio data: 80a1a80292a0884488cccd0c9088cd54cc88888888c8ccd0…

视频数据

0000   47 00 00 28 00 1a 1b 09 27 01 00 00 a0 00 00 1a   G..(....'.......
····   ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ··   ················
1a20   b4 9e 58                                          ..X
-------------------------------------------------------------------------
Real Time Messaging Protocol (Video Data)RTMP Header01.. .... = Format: 1..00 0111 = Chunk Stream ID: 7Timestamp delta: 40Timestamp: 129960 (calculated)Body size: 6683Type ID: Video Data (0x09)RTMP BodyControl: 0x27 (inter-frame H.264)0010 .... = Type: inter-frame (2).... 0111 = Format: H.264 (7)Video data: 010000a000001a12419aab49a8416c994c085ffffe8d340d…

流媒体传输 - RTMP 协议相关推荐

  1. 流媒体传输 - RTMP 协议报文分析

    握手之后,连接开始对一个或多个 chunk stream 进行合并.创建的每个块都有一个唯一 id 对其进行关联,这个 id 叫做 chunk stream id.这些块通过网络进行传输.传递时,每个 ...

  2. 流媒体传输 - HLS 协议

    HLS 全称是 HTTP Live Streaming,是一个由 Apple 公司提出的基于 HTTP 的媒体流传输协议,用于实时音视频流的传输.目前 HLS 协议被广泛的应用于视频点播和直播领域. ...

  3. RTMP协议深度解析:从原理到实践,掌握实时流媒体传输技术

    目录标题 1. 引言 1.1 流媒体传输技术的重要性 1.2 为什么选择RTMP协议 1.3 RTMP协议的发展与应用 2. RTMP协议基础 2.1 RTMP协议简介 2.2 RTMP协议与其他流媒 ...

  4. 流媒体封装格式和流媒体传输协议介绍

    1.流媒体封装格式介绍 一个流媒体文件由音频流和视频流两种数据组成. h264/mpeg4等就是视频流编码格式,视频流一般以帧的单位存在,i帧.p帧.b帧,帧率(frame rate)是每秒显示帧数( ...

  5. 视频云、流媒体以及相关协议的理解

    一.视频云 1.视频云是什么? 视频云是基于云计算技术的理念,采用视频作为"云端"向"终端"呈现处理结果的一种云计算方案,包括云储存.云转码.云直播.云加密.云 ...

  6. HLS,HTTP,RTSP,RTMP协议的区别

    HLS,HTTP,RTSP,RTMP协议的区别: 用HTTP方式: 先通过服务器将FLV下载到本地缓存,然后再通过NetConnection的本地连接来播放这个FLV,这种方法是播放本地的视频,并不是 ...

  7. iOS视频直播又一大神开源项目、RTMP 协议

    随着直播市场的火热,市场大军都逐步进入直播市场 ,腾讯旗下的NOW直播也不例外 先说说直播设计底层 一 .流媒体 1 - 伪流媒体 1.1 扫盲:边下载边播放 1.2 伪流媒体:视频不是实时播放的,先 ...

  8. 自制Linux功能板-新增功能(基于RTMP流媒体传输协议的视频监控)

    目录 一.ffmpeg工具 1.简介 2.移植相关库 二.RTMP的nginx服务器 1.简介 2.移植 三.运行测试 1.启动nginx 2.使用 FFmpeg 推流 引言:小板子能联网还有摄像头, ...

  9. 流媒体-RTMP协议-rtmpdump-flv封装解析(一)

    流媒体-RTMP协议-rtmpdump-flv封装解析(一) 流媒体-RTMP协议-librtmp库学习(二) 流媒体-RTMP协议-librtmp库学习-c++多线程实现rtmp推流flv文件(三) ...

最新文章

  1. 【数据结构与算法】之深入解析“课程表”的求解思路与算法示例
  2. java ehcahce刷新_springboot结合ehcache防止恶意刷新请求的实现
  3. matplotlib 子图超过4个_Matplotlib从入门到精通
  4. java使用itext将图片放到pdf模板的指定位置
  5. 雇佣K个工人的最小费用 Minimum Cost to Hire K Workers
  6. BarTender怎样同时打印自动日期和流水号?
  7. Java GUI 铁路售票系统
  8. 无线射频识别问答习题
  9. matlab 3维平滑,matlab 曲面平滑
  10. 华为OSN7500结构特点及产品定位相关知识
  11. matlab连通区域统计,MATLAB bwlabel函数 统计连通区域
  12. CodeForces 1023G. Pisces
  13. pytorch与torch的关系
  14. mysql 内连接、左连接会出现笛卡尔积?
  15. 一个简单的选品攻略,Shopee印尼站点卖家必看
  16. 计算机音乐谱大全eiei,彼岸吉他谱频道-求谱eiei,偶像练习生,求吉他谱,尤克里里谱,简谱,五线谱,钢琴谱,乐队总谱,乐谱-彼岸吉他 - 一站式吉他爱好者服务平台...
  17. dede 后台 一直显示验证码不正确的原因
  18. 一个好的PS笔刷(笔触)下载论坛
  19. 使用Python编写一个倒计时程序
  20. 北京朝阳一互联网公司被端,警方上门,23人被带走…这种开发千万别干

热门文章

  1. java高并发面试题目_列举Java高并发面试题附答案解析
  2. 金九银十准备季:Java IO流面试题(含答案)
  3. 微信小程序导航栏颜色不对问题
  4. 国行手机安装Google play store
  5. 解决本机不能访问 vbox 虚拟机 virtualbox
  6. Less语法介绍以及和CSS的区别(整理版)
  7. excel排名_excel中自动填上成绩名次的高低排序
  8. ToG产品_产品发布流程_2019_004
  9. 功能安全---AUTOSAR架构深度解析
  10. HTML5 canvas绘制音频,音乐可视化