Recipes← all recipesView on GitHub

Stream a video room to RTMP

VideoRTMP live streaming of video rooms

Start, update, or stop a video room's RTMP stream through REST using your streaming server URL.

videostreamingrtmp

The claim

The vendored REST spec, tools/openapi/rest.json, documents POST /api/video/rooms/{id}/streams with one required field, url. Its description reads “RTMP or RTMPS URL. This must be the address of a server accepting incoming RTMP/RTMPS streams.“ The 201 response carries the stream’s id, url and stream_type. You then address the stream by that id. The spec titles PUT /api/video/streams/{id} “Update stream” and requires the same url, and titles DELETE /api/video/streams/{id} “Delete stream”, answering 204. GET /api/video/rooms/{id}/streams lists a room’s streams. You reach the four as rooms.create_stream, streams.update, streams.delete and rooms.list_streams under client.video.

How it works

def start_stream(room_id, url=None):
    url = url or RTMP_URL
    return client.video.rooms.create_stream(room_id, url=url)

def move_stream(stream_id, url):
    return client.video.streams.update(stream_id, url=url)

def stop_stream(stream_id):
    return client.video.streams.delete(stream_id)

What the platform receives:

POST /api/video/rooms/<room_id>/streams
{"url": "rtmps://live.example.com/app/stream-key"}

PUT /api/video/streams/<stream_id>
{"url": "rtmp://backup.example.com/app/stream-key"}

DELETE /api/video/streams/<stream_id>

Keep the URL in RTMP_URL and out of the code, because it may contain a stream key. The room is one you already have; the spec documents the same url field on POST /api/video/conferences/{id}/streams for a prebuilt conference.

Limitations

You prove the requests and the documented shapes. Whether frames reach your RTMP server, when they start, and at what resolution are the platform’s side of a live session.

Creating the room is a different recipe, create-a-video-room-and-join-from-the-browser. This one starts from a room id.

What to change first

Change move_stream to send {"rtmp_url": url} and run the verifier. The exact-body assertion fails first, and assert_documented would fail next: the spec’s update body has exactly one property, and its name is url.