LIBRTMP(3)
π librtmp β the RTMP API, but make it make sense
okay bestie, sit down, hydrate, because we're talking about librtmp, aka the library side of RTMPDump's Real-Time Messaging Protocol API. she lives in section 3 of the manual (library functions, iykyk) and she is so much cooler than she looks. β¨
π LIBRARY
RTMPDump RTMP β and when you link against her you say -lrtmp. that's the whole vibe. π
πͺ SYNOPSIS
#include <librtmp/rtmp.h>
that's it. one include and you're in. π
πΈ DESCRIPTION
The Real-Time Messaging Protocol (RTMP, as the girlies call it) is what you use to stream multimedia content across a TCP/IP network. This API hands you most of the client functions plus a few server functions, so you can do RTMP, RTMP tunneled in HTTP (RTMPT), encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS), and the tunneled versions of the encrypted types (RTMPTE, RTMPTS). π
now, tea time: the basic RTMP spec has been published by Adobe, but this API was reverse-engineered without using the Adobe spec. so yeah, it may deviate from any published specification β but it usually duplicates the actual behavior of the original Adobe clients. iconic behavior honestly. π
The RTMPDump software package ships a basic client utility program in rtmpdump(1), some sample servers, and a library used to give you programmatic access to the RTMP protocol. This man page is the overview of the RTMP library routines. Those routines live in the -lrtmp library. There are also many other routines available that are not documented yet β so if you see a function you don't recognize, no you didn't. π
π the basic interaction (aka the whole plot)
here's the storyline, in order:
- Create a session handle with
RTMP_Alloc(). - Initialize it with
RTMP_Init(). - All session parameters get provided with
RTMP_SetupURL(). - Establish the network connection with
RTMP_Connect(). - Establish the RTMP session with
RTMP_ConnectStream(). - Read the stream with
RTMP_Read().
want to publish instead of watch? call RTMP_EnableWrite() before the RTMP_Connect() call, then use RTMP_Write() after the session is established. main character energy, honestly. π
While a stream is playing it may be paused and unpaused using RTMP_Pause(). The stream playback position can be moved using RTMP_Seek(). When RTMP_Read() returns 0 bytes, the stream is complete and may be closed using RTMP_Close(). Then the session handle is freed using RTMP_Free(). closure, literally. π¦
π§Ί the data + the URL
All data is transferred using FLV format. The basic session requires an RTMP URL, and the RTMP URL format is of the form:
rtmp[t][e|s]://hostname[:port][/app[/playpath]]
Plain rtmp, as well as tunneled and encrypted sessions, are supported. slay. β¨
Additional options may be specified by appending space-separated key=value pairs to the URL. Special characters in values may need to be escaped so the option parser doesn't misread them. The escape encoding uses a backslash followed by two hexadecimal digits representing the ASCII value of the character. E.g., spaces must be escaped as \20 and backslashes must be escaped as \5c. write that down bestie, fr fr. π
β¨ OPTIONS β¨
π Network Parameters
These options define how to connect to the media server.
socks=host:portβ Use the specified SOCKS4 proxy. that's the one. π§¦
π Connection Parameters
These options define the content of the RTMP Connect request packet. If correct values are not provided, the media server will reject the connection attempt. no pressure or anything. π
app=nameβ Name of application to connect to on the RTMP server. Overrides theappin the RTMP URL. Sometimes the librtmp URL parser cannot determine the app name automatically, so it must be given explicitly using this option. she's not psychic, ok? πtcUrl=urlβ URL of the target stream. Defaults tortmp[t][e|s]://host[:port]/app.pageUrl=urlβ URL of the web page in which the media was embedded. By default no value will be sent.swfUrl=urlβ URL of the SWF player for the media. By default no value will be sent.flashVer=versionβ Version of the Flash plugin used to run the SWF player. The default is"LNX 10,0,32,18". vintage, but make it work. πconn=type:dataβ Append arbitrary AMF data to the Connect message. The type must beBfor Boolean,Nfor number,Sfor string,Ofor object, orZfor null. For Booleans the data must be either0or1for FALSE or TRUE, respectively. Likewise for Objects the data must be0or1to end or begin an object, respectively. Data items in subobjects may be named, by prefixing the type with'N'and specifying the name before the value, e.g.NB:myFlag:1. This option may be used multiple times to construct arbitrary AMF sequences. E.g.
conn=B:1 conn=S:authMe conn=O:1 conn=NN:code:1.23 conn=NS:flag:ok conn=O:0
that's a whole AMF sandwich and you built it yourself. obsessed. π₯ͺ
π¬ Session Parameters
These options take effect after the Connect request has succeeded. patience, babe.
playpath=pathβ Overrides the playpath parsed from the RTMP URL. Sometimes the rtmpdump URL parser cannot determine the correct playpath automatically, so it must be given explicitly using this option.playlist=0|1β If the value is1or TRUE, issue aset_playlistcommand before sending theplaycommand. The playlist will just contain the current playpath. If the value is0or FALSE, theset_playlistcommand will not be sent. The default is FALSE.live=0|1β Specify that the media is a live stream. No resuming or seeking in live streams is possible. it's live, it's now, it's gone. π¦subscribe=pathβ Name of live stream to subscribe to. Defaults toplaypath.start=numβ Start atnumseconds into the stream. Not valid for live streams.stop=numβ Stop atnumseconds into the stream.buffer=numβ Set buffer time tonummilliseconds. The default is30000.timeout=numβ Timeout the session afternumseconds without receiving any data from the server. The default is120.
π Security Parameters
These options handle additional authentication requests from the server. the bouncer energy is strong here.
token=keyβ Key for SecureToken response, used if the server requires SecureToken authentication.jtv=JSONβ JSON token used by legacy Justin.tv servers. InvokesNetStream.Authenticate.UsherToken. throwback fr fr. πΌswfVfy=0|1β If the value is1or TRUE, the SWF player is retrieved from the specifiedswfUrlfor performing SWF Verification. The SWF hash and size (used in the verification step) are computed automatically. Also the SWF information is cached in a.swfinfofile in the user's home directory, so that it doesn't need to be retrieved and recalculated every time. The.swfinfofile records the SWF URL, the time it was fetched, the modification timestamp of the SWF file, its size, and its hash. By default, the cached info will be used for 30 days before re-checking.swfAge=daysβ Specify how many days to use the cached SWF info before re-checking. Use0to always check the SWF URL. Note that if the check shows that the SWF file has the same modification timestamp as before, it will not be retrieved again.
π EXAMPLES
An example character string suitable for use with RTMP_SetupURL():
"rtmp://flashserver:1935/ondemand/thefile swfUrl=http://flashserver/player.swf swfVfy=1"
look at her go. she's got a URL, a swfUrl, and swfVfy=1. triple threat. π
π ENVIRONMENT
HOMEβ The value of$HOMEis used as the location for the.swfinfofile.
π FILES
$HOME/.swfinfoβ Cache of SWF Verification information. yes it's living in your home dir, that's just where she lives. π«Ά
π SEE ALSO
π AUTHORS
Andrej Stepanchuk, Howard Chu, The Flvstreamer Team <http://rtmpdump.mplayerhq.hu>
β οΈ quick vibe check: this API was reverse-engineered without the Adobe spec, so it may deviate from published specifications β it usually duplicates the actual behavior of the original Adobe clients, but "usually" is doing a lot of heavy lifting there. and remember, many other routines exist that aren't documented yet. no cap.
and that's the whole page, bestie!! π this was RTMPDump v2.4, dated 2011-07-20, and yes she's still serving LIBRTMP(3) realness. go forth, RTMP_Alloc(), and slay. πβ¨π¦πΈπ
π¦ where this page comes from
- alpine 3.22: rtmpdump-doc 2.4_git20190330-r5 Β· GPL-2.0-or-later
- alpine 3.23: rtmpdump-doc 2.4_git20190330-r5 Β· GPL-2.0-or-later
- alpine 3.24: rtmpdump-doc 2.4_git20190330-r5 Β· GPL-2.0-or-later
- debian bookworm: librtmp-dev 2.4+20151223.gitfa8646d.1-2+b2
- debian trixie: librtmp-dev 2.4+20151223.gitfa8646d.1-2+b5
- fedora 44: librtmp-devel 2.6-4.fc44 Β· LGPL-2.0-or-later
- fedora 44: librtmp-devel 2.6-4.fc44 Β· LGPL-2.0-or-later
- nixos 26.05: rtmpdump 2.6
- ubuntu jammy: librtmp-dev 2.4+20151223.gitfa8646d.1-2build4
- ubuntu noble: librtmp-dev 2.4+20151223.gitfa8646d.1-2build7
- ubuntu questing: librtmp-dev 2.4+20151223.gitfa8646d.1-2build8
- ubuntu resolute: librtmp-dev 2.4+20151223.gitfa8646d.1-3 Β· GPL-2.0-or-later
- ubuntu stonking: librtmp-dev 2.6-1 Β· GPL-2.0-or-later
- Copyright 2011 Howard Chu
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms