RTMP: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
No edit summary
(Remove some empty lines from table.)
 
(19 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Real Time Messaging Protocol is a proprietary protocol created by Macromedia used for accessing streaming multimedia and for elementary remote function calls.
[http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol Real Time Messaging Protocol] is a proprietary protocol created by [[Macromedia]] used for accessing streaming multimedia and for elementary remote function calls.


http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol
*Description: http://rtmpy.org/wiki/RTMP
*Server: http://www.osflash.org/rtmp_os
*Server: http://osflash.org/red5
*Server: http://www.rtmpd.com/
*Server: http://erlyvideo.org/
*Server: http://code.google.com/p/rubyizumi/
*Client: http://swfdec.freedesktop.org/
*RTMPdump - http://rtmpdump.mplayerhq.hu
*Videolan - http://www.videolan.org
*Specifications (RTMPE) : http://lkcl.net/rtmp/


mostly used for streaming flv. example: rtmp://fcs.fox.speedera.net/vod/fcs.fox/simpsons/sexy_video.flv
Variations
# RTMP uses port 1935.
# RTMPT (RTMP Tunnelled) uses port 80 (protocol is encapsulated by HTTP).
# RTMPS (RTMP Secure) uses port 443 (protocol is encapsulated by HTTPS).
 
Mostly used for streaming [[Flash Video]].
 
== Protocol technical description ==
 
Streaming consists of exchanging messages with server by TCP protocol.
 
It is worth noting that path in URL serves two functions: first two directory levels (if present, only one otherwise) serve as an application name, the rest is played file name. Prefixed with colon (for [[FLV]]) or "mp4:" (for [[MP4]]) it is called "playpath".
 
=== Handshake ===
==== Old Plain Handshake ====
This type of handshake is described everywhere (but not working with all servers):
 
# client sends 0x03 and 1536 bytes of random data
# server sends 0x03 and 1536 bytes of its own random data
# server sends 1536 bytes of data, containing exactly what client has sent
# client sends 1536-bytes of server-generated data back to server
 
==== Digested Handshake ====
'''TODO'''
 
=== Common packet passing ===
Each packet is transmitted in chunks. If packet is bigger than chunk size, each new chunk is prefixed with <code>0xC0+stream_id</code> byte.
 
Initial chunk size is 128 (some sources say it's 64 for audio packets but 128 otherwise). Server (client too?) may change chunk size any time.
 
=== Packet header ===
 
{| class=wikitable style="width:100%; height:200px" border="1"
|-
! Field
! Size
! Meaning
|-
| Packet header size
| 2 bits
| 0 - 12 bytes, 1 - 8 bytes (no ext. timestamp), 2 - 4 bytes (header data is taken from previous packet with the same stream_id), 3 - next chunk marker
|-
| Stream ID
| 6 bits
| packet stream id, usually has some relation to packet contents
|-
| Stream ID additional data
| 0/8/16 bits LE
| it contains <code>stream ID - 64</code>. For stream ID < 64 real value is stored in previous 6 bits and this field is not written; for stream ID < 320 previous 6 bits are zero and this field is single byte, otherwise previous 6 bits contain value "1" and this field is written as two bytes.
|-
| Timestamp
| 24 bits BE
| packet timestamp
|-
| Packet type
| 8 bits
| describes what data this packet holds
|-
| Packet size
| 24 bits BE
|
|-
| ?
| 32 bits LE
| probably contains extended timestamp when it's too big to fit into 24 bits
|}
 
Usual stream ID meanings:
* 2 - network-related stuff
* 3 - actions
* 8 - video data
* 9 - audio data
 
Packet types:
* 1 - change chunk type, contains 32-bit BE number with new chunk size
* 3 - "bytes read" message
* 4 - ping
* 5 - server bandwidth, contains 32-bit BE number with server bandwidth
* 6 - client bandwidth, contains 32-bit BE number with client bandwidth
* 8 - audio data, as in [[FLV]] starts with flags
* 9 - video data, as in [[FLV]] starts with flags
* 20 - invoke (server or client function call), body contains arguments to the call
* 22 - FLV metadata
 
=== Typical workflow for playing ===
* Client handshakes with server
* Client sends invoke with 'connect'
* Server responds with either '_result' or '_error' invoke
* If succeeded client invokes 'createStream'
* Server may respond with something
* If succeeded client invokes 'play'
 
== Samples ==
{| class=wikitable style="width:100%; height:200px" border="1"
|-
! Audio
! Video
! URL
|-
| mp3
| vp6f
| rtmp://cp9950.edgefcs.net/ondemand/comedystor/_!/com/dailyshow/TDS/season_03/episode_100/ds_03100_08_blm_480.flv
|-
| mp3
| vp6f
| rtmp://wdiguk.fcod.llnwd.net:1935/a2334/d1/xd/disneyxd.co.uk/JIMMY_2_SHOES_SHORTS_S1_E1_sw.flv
|-
| mp3
| vp6f
| rtmp://directv.fcod.llnwd.net/a517/d1/com/lp/testdrive/active_channel-hack.flv
|-
| mp3
| vp6f
| rtmp://ciena.fv.miisolutions.net/ciena/flash/LynneMilton_256l.flv
|-
| mp3
| vp6f
| rtmp://flvideo.wwe.com/wwevideo/flv/kids/2008/october8-14/kids_cena_wiffle_large.flv
|-
| mp3
| vp6a
| rtmp://advancedmethod.flashsvc.vitalstreamcdn.com/advancedmethod_vitalstream_com/_definst_/airtime/Q4.flv
|-
|
|
| rtmp://www.yozik.com/yo2413/30393.mp3
|-
| mp3
| flv
| rtmp://fsapfs.fplive.net/fsap/Videos/foie_gras_uk_high.flv
|-
| mp3
| vp6a
| rtmp://fms.04C7.edgecastcdn.net/0004C7/t-mobilemytouch/videos/home/phil_video
|-
| aac
| h264
| rtmp://sony.flash.internapcdn.net/sony_vitalstream_com/_definst_/mp4:NAB2009-Video/Sony_Professional_Media.f4v
|-
|
| text
| rtmp://flowplayer.org:1935/fastplay/video/buffalo.srt
|-
| mp3
|
| rtmp://fl9.maelstrom.jet-stream.nl:80/vod/vdoxadmin/jeroen/bunny.mp3
|-
| aac
|
| rtmp://cp72151.live.edgefcs.net/live/WCHB-AM@10665
|-
|
|
| rtmpe://wbads.fcod.llnwd.net/a2383/o25/mp4:thewb/video/thegeorgecarlinshow/01/thegeorgecarlinshow_01_01_700kbps.mp4
|-
| mp3
| h264
| rtmp://video-12.radioradicale.it/store-51/mp4:FL532501.f4v
|-
| mp3
|
| rtmpe://akafms-music01.myspacecdn.com/ondemand/mp3:86/std_e647631bd0c6e9197654c64dce7e4e12
|-
|
|
| rtmp://octopus.xuggle.com/scatterchat/audience
|}
 
streams requiring swfurl / pageurl:
<pre>
rtmpdump -f "WIN 10,0,12,36" -s "http://www.teennick.com/theclick/turboclick/swf/bb_flv_player_nick.swf" -p "http://www.teennick.com/theclick/?titleId=23721&ctitle=No%20Vomments&owner=thecolin" -r rtmp://viacom.fcod.llnwd.net/a1624/e17/gsp.thencomstor/the-n.com/the_assistants/tn_ass_112_fle_o5g_rt162572_480x360_700.flv -o ass12.flv
</pre>
 
live streams:
<pre>
rtmpdump --live -r rtmp://flash1.bpmnetworks.com/live/ktv -o cra.flv -s "http://www2.k-tv.at/streaming/playbackengine.swf" -V -f "WIN 10,0,12,36" -p "http://www2.k-tv.at/streaming/index.html"
</pre>
 
<pre>rtmpdump -r rtmp://kanald.tbt.com.tr:80/cnnturk/CNNTurk1 -o output.flv --live -f "WIN 10,0,12,36" -s "http://www.cnnturk.com/swf/player_cnnturk_secure.swf" </pre>
 
[[Category:Networking Protocols]]

Latest revision as of 03:30, 14 February 2012

Real Time Messaging Protocol is a proprietary protocol created by Macromedia used for accessing streaming multimedia and for elementary remote function calls.

Variations

  1. RTMP uses port 1935.
  2. RTMPT (RTMP Tunnelled) uses port 80 (protocol is encapsulated by HTTP).
  3. RTMPS (RTMP Secure) uses port 443 (protocol is encapsulated by HTTPS).

Mostly used for streaming Flash Video.

Protocol technical description

Streaming consists of exchanging messages with server by TCP protocol.

It is worth noting that path in URL serves two functions: first two directory levels (if present, only one otherwise) serve as an application name, the rest is played file name. Prefixed with colon (for FLV) or "mp4:" (for MP4) it is called "playpath".

Handshake

Old Plain Handshake

This type of handshake is described everywhere (but not working with all servers):

  1. client sends 0x03 and 1536 bytes of random data
  2. server sends 0x03 and 1536 bytes of its own random data
  3. server sends 1536 bytes of data, containing exactly what client has sent
  4. client sends 1536-bytes of server-generated data back to server

Digested Handshake

TODO

Common packet passing

Each packet is transmitted in chunks. If packet is bigger than chunk size, each new chunk is prefixed with 0xC0+stream_id byte.

Initial chunk size is 128 (some sources say it's 64 for audio packets but 128 otherwise). Server (client too?) may change chunk size any time.

Packet header

Field Size Meaning
Packet header size 2 bits 0 - 12 bytes, 1 - 8 bytes (no ext. timestamp), 2 - 4 bytes (header data is taken from previous packet with the same stream_id), 3 - next chunk marker
Stream ID 6 bits packet stream id, usually has some relation to packet contents
Stream ID additional data 0/8/16 bits LE it contains stream ID - 64. For stream ID < 64 real value is stored in previous 6 bits and this field is not written; for stream ID < 320 previous 6 bits are zero and this field is single byte, otherwise previous 6 bits contain value "1" and this field is written as two bytes.
Timestamp 24 bits BE packet timestamp
Packet type 8 bits describes what data this packet holds
Packet size 24 bits BE
? 32 bits LE probably contains extended timestamp when it's too big to fit into 24 bits

Usual stream ID meanings:

  • 2 - network-related stuff
  • 3 - actions
  • 8 - video data
  • 9 - audio data

Packet types:

  • 1 - change chunk type, contains 32-bit BE number with new chunk size
  • 3 - "bytes read" message
  • 4 - ping
  • 5 - server bandwidth, contains 32-bit BE number with server bandwidth
  • 6 - client bandwidth, contains 32-bit BE number with client bandwidth
  • 8 - audio data, as in FLV starts with flags
  • 9 - video data, as in FLV starts with flags
  • 20 - invoke (server or client function call), body contains arguments to the call
  • 22 - FLV metadata

Typical workflow for playing

  • Client handshakes with server
  • Client sends invoke with 'connect'
  • Server responds with either '_result' or '_error' invoke
  • If succeeded client invokes 'createStream'
  • Server may respond with something
  • If succeeded client invokes 'play'

Samples

Audio Video URL
mp3 vp6f rtmp://cp9950.edgefcs.net/ondemand/comedystor/_!/com/dailyshow/TDS/season_03/episode_100/ds_03100_08_blm_480.flv
mp3 vp6f rtmp://wdiguk.fcod.llnwd.net:1935/a2334/d1/xd/disneyxd.co.uk/JIMMY_2_SHOES_SHORTS_S1_E1_sw.flv
mp3 vp6f rtmp://directv.fcod.llnwd.net/a517/d1/com/lp/testdrive/active_channel-hack.flv
mp3 vp6f rtmp://ciena.fv.miisolutions.net/ciena/flash/LynneMilton_256l.flv
mp3 vp6f rtmp://flvideo.wwe.com/wwevideo/flv/kids/2008/october8-14/kids_cena_wiffle_large.flv
mp3 vp6a rtmp://advancedmethod.flashsvc.vitalstreamcdn.com/advancedmethod_vitalstream_com/_definst_/airtime/Q4.flv
rtmp://www.yozik.com/yo2413/30393.mp3
mp3 flv rtmp://fsapfs.fplive.net/fsap/Videos/foie_gras_uk_high.flv
mp3 vp6a rtmp://fms.04C7.edgecastcdn.net/0004C7/t-mobilemytouch/videos/home/phil_video
aac h264 rtmp://sony.flash.internapcdn.net/sony_vitalstream_com/_definst_/mp4:NAB2009-Video/Sony_Professional_Media.f4v
text rtmp://flowplayer.org:1935/fastplay/video/buffalo.srt
mp3 rtmp://fl9.maelstrom.jet-stream.nl:80/vod/vdoxadmin/jeroen/bunny.mp3
aac rtmp://cp72151.live.edgefcs.net/live/WCHB-AM@10665
rtmpe://wbads.fcod.llnwd.net/a2383/o25/mp4:thewb/video/thegeorgecarlinshow/01/thegeorgecarlinshow_01_01_700kbps.mp4
mp3 h264 rtmp://video-12.radioradicale.it/store-51/mp4:FL532501.f4v
mp3 rtmpe://akafms-music01.myspacecdn.com/ondemand/mp3:86/std_e647631bd0c6e9197654c64dce7e4e12
rtmp://octopus.xuggle.com/scatterchat/audience

streams requiring swfurl / pageurl:

rtmpdump -f "WIN 10,0,12,36" -s "http://www.teennick.com/theclick/turboclick/swf/bb_flv_player_nick.swf" -p "http://www.teennick.com/theclick/?titleId=23721&ctitle=No%20Vomments&owner=thecolin" -r rtmp://viacom.fcod.llnwd.net/a1624/e17/gsp.thencomstor/the-n.com/the_assistants/tn_ass_112_fle_o5g_rt162572_480x360_700.flv -o ass12.flv

live streams:

rtmpdump --live -r rtmp://flash1.bpmnetworks.com/live/ktv -o cra.flv -s "http://www2.k-tv.at/streaming/playbackengine.swf" -V -f "WIN 10,0,12,36" -p "http://www2.k-tv.at/streaming/index.html" 
rtmpdump -r rtmp://kanald.tbt.com.tr:80/cnnturk/CNNTurk1 -o output.flv --live -f "WIN 10,0,12,36" -s "http://www.cnnturk.com/swf/player_cnnturk_secure.swf"