Oct 23

RTMP protocol, handling and downloading

Category: Linux,multimedia   — Published by tengo on October 23, 2008 at 10:00 am

The RTMP (Real Time Messaging Protocol) protocol is a proprietary and closed source protocol developed by Adobe which is used to stream (mainly FLV) video off a media server, like the the Adobe Flash Media Server. Most probably you've come across this protocol while watching video on one of the video sites out there.

About RTMP

RTMP is not rtsp (open, RFC2326) and not mms (Microsoft). It uses (in its TCP variant) a persistent binary data connection to enable a player application to deliver constant quality. Most (all) players are implemented in Flash. Besides the plain TCP versions, there are variants called RTMPT (which allows tunneling) and RTMPS (for https transmissions).

A more detailed overview explanation is available over at Wikipedia. According to the whitepaper, rtmp uses port 1935 (TCP), 443 (HTTP/SSL) and 80 (plain HTTP).

Development on deciphering the protocol is advancing. The protocol itself has been mostly reverse engineered by the Red5 project and others, making it available for free or open-source media server implementations.

Recording RTMP or downloading it

Most sites use a SWF/Flash player object embedded into a webpage to playback video streams delivered via rtmp. Furthermore, many player implementations seem to access a configuration xml file (instead of the video file URL directly) that, besides other stuff, stores the actual rtmp://path/to/flv/file path in it.At the moment there are only shaky solutions available to download data that is served via rtmp://. This is why so many content owners and video portals handling "watch-only" video (like hulu.com, BBC iPlayer, Mogulus) are using it in the first place.

The ingenious Mplayer, sadly, is still not processing it, neither for playback, nor for recording by using the "-dumpstream" switch. Write a comment if you know that this has changed!

Solutions that seem to support rtmp are: xbmc (linux, playback), vlc (multi-platform, serve in rtmp) ,  gnash project (linux, playback via the libamf library)  and rumours go that there's a ffmpeg rtmp and libCurl is working on it. If you are on windows, orbit downloader seems to download rtmp.

And of course, as everything rtmp does travels over your network connection, you can dump/save everything via libpcap if you manage to get the binary dump right (I can't). For the knowleadgable it might be helpful to have a look at Braden’s libpcap program.