Working with RTMP servers

This section will cover methods for organizing broadcasting via the RTMP protocol from your application or infrastructure using the Restful API.

These methods can be called from any type of client or server, whether it's an ajax request from a browser, or the Android operating system.

You don't need to install anything.

To get started, all you need is an API token, which gets purchased and assigned to you the moment you launch an instance with Callaba Cloud. For production ingest and monitoring, see continuous streaming. For playback integration and analytics, use video api. Recommended product path: Ingest & route, Player & embed. For this workflow, Player & embed is the most direct fit., and scaling guide.

If you haven't already done so, please follow the link. It will take no more than 5 minutes.

For each method of establishing streaming over the RTMP protocol, CURL requests and JSON responses will be presented as an example, as well as all possible parameters with RTMP settings will be considered.

Using these methods, you will be able to broadcast RTMP from your infrastructure or application. If you need something extra that is not in the API, you can contact our technical support and request customization from the internal Callaba Engine development team.

If you have any questions, please contact us at: [email protected]
We will respond to you within 24 hours.

Happy developing and streaming!

Creating an RTMP server
Expand
POST
/api/rtmp-servers/create

Creates an RTMP server on the specified port, with parameters.

Once the request is executed, Callaba Engine is ready to receive and send SRT streams.

Publish SRT stream:

ffmpeg -re -i "./videos/awesome-video.mp4" -f flv "rtmp://100.204.59.138:1945/live/rtmp-stream-01"

Receive SRT stream:

ffplay -i "rtmp://100.204.59.138:1945/live/rtmp-stream-01"

If ffmpeg is not available, you can send and receive a stream from OBS, use this tutorial

Query parameters
server_name
string | required | unique

RTMP server name. This parameter must be unique and is required.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Free Video Hosting and Rtmp.

server_type
string | required

RTMP server type. The following types are supported

  • SERVER_TYPE_RTMP - creates an RTMP server for production usage.
  • SERVER_TYPE_RTMP_DEBUG - creates an RTMP server for testing and diagnostic (for the internal development team).

Use SERVER_TYPE_RTMP if you are developing your own application based on the Callaba Engine. For production ingest and monitoring, see continuous streaming. For playback integration and analytics, use video api. Recommended product path: Ingest & route, Player & embed., and scaling guide. For implementation details, continue with SRT Servers. server_type and Create, edit, start and delete SRT Server or Gateway using Callaba Cloud.

server_buflen
number | required

Server receiver buffer in seconds. Default value is 5.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Free Video Hosting and RTMP Servers server_active.

server_port
number | required | unique

RTMP server port. Acceptable values are from 1 to 65535.

 

Since RTMP uses TCP as a transport, after creating an RTMP server on the specified port, the corresponding TCP port will be used.

To find out if a port is free, use the /api/ports/getAll method from the ports section

 

IMPORTANT. Make sure the specified port is open in your infrastructure and AWS infrastructure.

, and scaling guide. For this workflow, teams usually combine Ingest & route, Video platform API, and 24/7 streaming channels. For implementation details, continue with SRT Servers. server_port and SRT Servers. server_receiver_port.

server_active
boolean | optional

Controls the state of the server. Possible values are true or false. Disabling the RTMP server will make it drop all connections and free up resources. The default value is true.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Video conferencing properties active and Create a Virtual Events Platform Setup CloudFront CDN for Live Events. Part I.

Creating an RTMP server
cURL
curl -X 'POST' \
'http://100.204.59.138/api/rtmp-servers/create' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d '{
"server_name": "Awesome RTMP server",
"server_type": "SERVER_TYPE_RTMP",
"server_buflen": 5,
"server_port": 1935,
"server_active": true
}'
Response
id
ObjectId | unique

A unique identifier of the RTMP server. Is an object and looks similar to the hashed string. As Callaba Engine uses MongoDb, it's a common practice to consider it as an ObjectId type, to avoid introducing unnecessary entities. Use this option to get, edit, delete a specific RTMP server. For production ingest and monitoring, see continuous streaming. For playback integration and analytics, use video api. Recommended product path: Ingest & route, Player & embed., and scaling guide. For implementation details, continue with SRT Servers. Create. id and Restream response Create. id.

server_created
date

Returns the creation date of the RTMP server

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with RTMP servers response server_updated and RTMP servers response getById object.

Response: Creating an RTMP server
JSON
{
"id": "621f581ca8b8090032a4a6c6",
"server_name": "Awesome RTMP server",
"server_type": "SERVER_TYPE_RTMP",
"server_buflen": "5",
"server_port": "1935",
"server_active": true,
"server_user_id": "620beb06137bb3002c8f600a",
"server_created": "2022-03-02T11:42:20.302Z"
}
Editing the RTMP Server
Expand
POST
/api/rtmp-servers/update

Use this method to change the settings of a previously created server by its ID.

Once the method is executed, the server will be stopped and all its clients will be disconnected. Then the server would be re-started with the new parameters.

Use the same query parameters as when creating the server

Query parameters
id
ObjectId | required

id - identifier of the server to be changed.

For implementation details, continue with SRT servers change id and Akamai Cdn.

Editing the RTMP Server
cURL
curl -X 'POST' \
'http://1.2.3.4/api/rtmp-servers/update' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d '{
"id": "621f581ca8b8090032a4a6c6",
"server_name": "Awesome RTMP Server",
"server_type": "SERVER_TYPE_RTMP",
"server_port": 1936,
"server_buflen": 5,
"server_active": true
}'
Response
id
ObjectId

A unique identifier of the RTMP server.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with RTMP Servers. server_name and Free Video Hosting.

server_updated
date

Returns the date the RTMP server was last modified

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Recording response updated and Players response updated.

Response: Editing the RTMP Server
JSON
{
"id": "621f581ca8b8090032a4a6c6",
"server_name": "Awesome RTMP Server",
"server_type": "SERVER_TYPE_RTMP",
"server_buflen": "5",
"server_port": "1936",
"server_active": true,
"server_user_id": "620beb06137bb3002c8f600a",
"server_created": "2022-03-02T11:42:20.302Z",
"server_modified": "2022-03-02T11:53:59.828Z"
}
Stopping the RTMP server
Expand
POST
/api/rtmp-servers/stop

Use this method if you need to stop an RTMP server by its id. 

Query parameters
id
ObjectId | required

id - identifier of the server to be stopped.

For implementation details, continue with Create, edit, start and delete SRT Server or Gateway using Callaba Cloud and SRT servers stop id. For this workflow, Ingest & route is the most direct fit.

Stopping the RTMP server
cURL
curl -X 'POST' \
'http://1.2.3.4/api/rtmp-servers/stop' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d '{
"id": "621f581ca8b8090032a4a6c6"
}'
Response
success
boolean

Success result. Possible value: true or false.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Players remove success and Players response change success. For implementation details, continue with Players response start success and Players response stop success. For implementation details, continue with Recording remove success and Recording response change success.

Response: Stopping the RTMP server
JSON
{
"success": true
}
Starting the RTMP server
Expand
POST
/api/rtmp-servers/start

Use this method if you need to start an RTMP server by its id.

Query parameters
id
ObjectId | required

id - identifier of the server to be started.

For this workflow, teams usually combine Calls & webinars, Video platform API, and Player & embed. For implementation details, continue with SRT servers start id and Recording start id. For this workflow, Ingest & route is the most direct fit. For implementation details, continue with Enhancing B2B marketing with Live Video and How to multi-stream from Zoom to Twitch, Youtube and Facebook.

Starting the RTMP server
cURL
curl -X 'POST' \
'http://1.2.3.4/api/rtmp-servers/start' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d '{
"id": "621f581ca8b8090032a4a6c6"
}'
Response
success
boolean

Success result. Possible value: true or false.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Players remove success and Players response change success. For implementation details, continue with Players response start success and Players response stop success. For implementation details, continue with Recording remove success and Recording response change success.

Response: Starting the RTMP server
JSON
{
"success": true
}
Getting a list of RTMP servers
Expand
POST
/api/rtmp-servers/getAll

Use this method to get a list of RTMP servers

Query parameters
This method has no parameters
Getting a list of RTMP servers
cURL
curl -X 'POST' \
'http://1.2.3.4/api/rtmp-servers/getAll' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d ''
Response
array of RTMP servers
array

Returns an array of RTMP servers

For this workflow, teams usually combine Video platform API, Calls & webinars, and Player & embed. For this workflow, 24/7 streaming channels is the most direct fit. For implementation details, continue with Players response getById object and recording response getById object.

Response: Getting a list of RTMP servers
JSON
[
{
"id": "621f581ca8b8090032a4a6c6",
"server_name": "Awesome RTMP Server",
"server_type": "SERVER_TYPE_RTMP",
"server_buflen": "5",
"server_port": "1936",
"server_active": true,
"server_created": "2022-03-02T11:42:20.302Z",
"server_modified": "2022-03-02T11:58:38.389Z"
Getting server RTMP information by ID
Expand
POST
/api/rtmp-servers/getById

Use this method if you need to get information about the server created by your application.

Query parameters
id
ObjectId | required

id - identifier of the server

For implementation details, continue with Akamai Cdn and Content protection and DRM safeguarding content from piracy and unauthorized access.

Getting server RTMP information by ID
cURL
curl -X 'POST' \
'http://1.2.3.4/api/rtmp-servers/getById' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d '{
"id": "621f581ca8b8090032a4a6c6"
}'
Response
Object of RTMP server
object

Returns an object of RTMP server

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with RTMP servers response server_updated and RTMP servers server_created.

Response: Getting server RTMP information by ID
JSON
{
"id": "621f581ca8b8090032a4a6c6",
"server_name": "Awesome RTMP Server",
"server_type": "SERVER_TYPE_RTMP",
"server_buflen": "5",
"server_port": "1936",
"server_active": true,
"server_user_id": "620beb06137bb3002c8f600a",
"server_created": "2022-03-02T11:42:20.302Z",
"server_modified": "2022-03-02T11:58:38.389Z"
}
Removing the RTMP server
Expand
DELETE
/api/rtmp-servers/remove

Use this method if you need to remove an RTMP server by its id. 

Query parameters
id
ObjectId | required

id - identifier of the server to be removed.

For implementation details, continue with Content protection and DRM safeguarding content from piracy and unauthorized access and SRT servers remove id.

Removing the RTMP server
cURL
curl -X 'DELETE' \
'http://1.2.3.4/api/rtmp-servers/remove' \
-H 'accept: application/json' \
-H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMGJlYjA2MTM3YmIzMDAyYzhmNjAwYSIsImlhdCI6MTY0NTczMTE5OCwiZXhwIjoxNjQ4MzIzMTk4fQ.8JuWlhn4lEY11hAUsaw10O_5-HiKH_GuQq8k2qRBvbA' \
-H 'Content-Type: application/json' \
-d '{
"id": "621f581ca8b8090032a4a6c6"
}
Response
success
boolean

Success result. Possible value: true or false.

, and scaling guide. For this workflow, teams usually combine Ingest & route, 24/7 streaming channels, and Paywall & access. For implementation details, continue with Players remove success and Players response change success. For implementation details, continue with Players response start success and Players response stop success. For implementation details, continue with Recording remove success and Recording response change success.

Response: Removing the RTMP server
JSON
{
"success": true
}