Login

Get started with RTMPS streams

Starting a live stream is easy with FastPix. Once you've created it, you'll find numerous options to connect live video and kick off your broadcast.

This guide will walk you through setting up your live stream using FastPix API, followed by broadcasting with OBS.

Step 1: Get an API Access Token

After signing up with FastPix, all you now need is to generate your API access token. FastPix live streaming API utilizes a token key pair comprising a Token ID and Secret Key for authentication. Navigate to Settings and create a new Access Token in the Access Token settings within your Organization settings dashboard.


Step 1: Get an API Access Token

Access Tokens play a crucial role in FastPix, allowing you to securely interact with the platform. Once you click on Generate new token, a pop-up will appear with input fields to create your new Access Token.



Understanding workspace

Workspaces act as parent containers for Access Tokens, Signing Keys, and other elements in FastPix. When you create an Access Token, it is associated with a specific Workspace. For now, let’s focus on the Development workspace, which is ideal for testing and experimentation.

Access token permissions

Access Tokens come with different permissions, regulating the actions and extent of modifications they can perform. As you follow this guide, ensure that your Access Token has both FastPix Video Read and Write permissions. This ensures that you can read existing videos and upload new ones seamlessly.

To keep track of your Access Tokens within your application or project, you can assign them any name, like “Test”. This helps in managing and identifying them easily.

When you’re ready, proceed by clicking the ‘Generate access token’ button. This will create a new Access Token ID and Secret Key for you.



With your newly generated Access Token ID and Secret Key, you’re now set to start your first live stream with FastPix. Remember, proper management of your Access Tokens is crucial for the smooth operation of your application.


IMPORTANT

To keep the Access Token information (Secret Key) for future use, download an workspace file (.env) that stores these details. FastPix doesn’t store the exact Secret Key.


It's important to note that FastPix only stores a secret hash, not the Secret Key itself. If the Secret Key is lost, FastPix cannot retrieve it, necessitating the creation of a new Access Token. Also, make sure to keep your Secret Key safe and avoid exposing it, which might cause a security breach on your account.


Step 2: Create a live stream

To create your first live streaming with FastPix, use the below API reference:

POST request to the create a new stream endpoint.

The username and password that you would use in the POST request can be replaced with your own access token details (Access Token ID and Secret Key) generated from the FastPix Organization dashboard.


curl -X POST 'https://v1.fastpix.io/live/streams' \
	 --user {Access Token ID}:{Secret Key} \
     -H 'Content-Type: application/json' \
     -d '
{
  "playbackSettings": {
    "accessPolicy": "public"
  },
  "inputMediaSettings": {
    "maxResolution": "1080p",
    "reconnectWindow": 60,
    "mediaPolicy": "public",
    "metadata":{ "livestream_name": "fastpix_livestream" },
    "enableDvrMode": False
 }
}'

Let’s talk about the request parameters


accessPolicy: Determines if access to the streamed content is kept private or available to all.
Possible values: public or private

maxResolution: Max resolution can be used to control the maximum resolution your media is encoded, stored, and streamed at. Accepts only 1080p, 720p, 480p resolutions and by default it’s set to 1080p.

reconnectWindow: It mainly works when any network issue occurs. The Reconnect Window determines how long the system waits (in seconds) before declaring a live stream as over; due to a disconnect. If not specified, it defaults to 60 seconds.

mediaPolicy: This flag determines the access policy (public/private) for media content created once the live stream has concluded. It specifies how the recorded stream will be handled in terms of availability, permissions, and visibility. Based on the flag's configuration, the media can either be made publicly accessible, restricted to certain users, or archived for internal use. This ensures proper control over the distribution and access of content after the live event has ended.

metadata: Arbitrary user-supplied metadata that will be included in the stream details and related webhooks. This can be used to store your own ID for a video along with the livestream. You can have maximum of 255 characters and upto 10 entries are allowed.

enableDvrMode: This parameter determines whether DVR (Digital Video Recorder) mode is available for users during a live stream. When DVR mode is enabled (i.e., if the flag is set to true), users can pause, rewind, or replay parts of the live stream, giving them more control over how they view the broadcast.

If the flag is set to false (which is the default value if no specific input is provided when creating the live stream), DVR functionality will be disabled, and users will only be able to watch the stream in real-time without the ability to go back or pause. This feature provides flexibility for viewers, especially in live broadcasts where they may want to rewatch or catch up on parts they missed.


NOTE

To experience DVR Functionality enableRecording must be set to true.


Step 3: Getting a 201 successful response

You'll receive a Playback ID and a Stream Key in the response.


{
  "success": true,
  "data": {
    "streamId": "fa7f8c0950ea48ebcc5ef9de8c23deaa",
    "streamKey": "3dc5d7641f918baa083a5c52a5bd9cbckfa7f8c0950ea48ebcc5ef9de8c23deaa",
    "srtSecret": "c51739512d0088d98a46925c9b74c73akfa7f8c0950ea48ebcc5ef9de8c23deaa",
    "trial": false,
    "status": "idle",
    "maxResolution": "1080p",
    "maxDuration": 43200,
    "createdAt": "2024-10-15T08:48:31.551351Z",
    "reconnectWindow": 60,
    "enableRecording": true,
    "mediaPolicy": "public",
    "metadata": {
      "livestream_name": "fastpix_livestream"
    },
    "enableDvrMode": false,
    "playbackIds": [
      {
        "id": "4e43ec52-4775-4f68-a3ff-a57d8a59bba8",
        "accessPolicy": "public"
      }
    ],
    "srtPlaybackResponse": {
      "srtPlaybackStreamId": "playfa7f8c0950ea48ebcc5ef9de8c23deaa",
      "srtPlaybackSecret": "490e707dd4d165c9e38d261b252f9457kfa7f8c0950ea48ebcc5ef9de8c23deaa"
    }
  }
}

Let’s talk about response parameters


streamId: Once a live stream is created, a unique identifier is assigned to the stream.

streamKey: A stream key is a string of characters generated by FastPix when you create a live stream event. This string acts like a unique identifier or password, which is necessary to link your broadcasting software (like OBS) with FastPix.


PLEASE NOTE

The main purpose of a stream key is to ensure that your live video stream is correctly directed from your broadcasting software to the intended platform. This key allows third-party live stream services, such as OBS, to authenticate and send the live video feed to the platform.


Why is a stream key important?

  • Authentication: The stream key authenticates your broadcasting software with the streaming platform. This ensures that the platform knows which account and which specific event the video feed belongs to.
  • Security: The stream key acts like a password. Only someone with the correct stream key can send a live video feed to your streaming event. This helps prevent unauthorized users from broadcasting on your channel.
  • Uniqueness: Each stream key is unique to a specific live stream event. This means that even if someone has your previous stream key, they cannot use it for future streams. You will get a new stream key for each new live event you create.

srtSecret: The SRT Secret Key is used in relation to the SRT protocol for secure live stream broadcasting. This key ensures encrypted transmission of media over the SRT connection, safeguarding the stream from unauthorized access or tampering. For more detailed information on SRT, please refer to this guide .

trial: The flag indicates whether the organization you logged into is subscribed to either the enterprise plan or the test plan. The system automatically fetches the organization’s plan status and assigns a value based on this subscription.


PLEASE NOTE

PATCH and Simulcast functionalities won’t work for test streams (i.e. when provided true).


maxDuration: This setting defines the maximum time limit for which a customer can conduct a live stream. Once the live stream reaches this time limit, it will automatically stop. This feature is particularly useful for managing resources and ensuring that streams adhere to the plan's restrictions.

  • Depending on the organization's plan, the system retrieves a maxDuration value.
  • For organizations with a test plan, the maximum duration is 300 seconds (5mins).
  • For those with an Pay as you go plan, the maximum duration is 43,200 seconds (12 hours).

status: It gives you the current live stream status.

  • idle indicates that no live stream is currently in progress (the stream hasn't started yet).
  • preparing signifies that the stream is in the preprocessing phase, preparing to transition to the active state.
  • active means that the live stream is ongoing (the video is currently being streamed).
  • disabled means that streaming has been stopped, and no further streams can be published.

📘

PLEASE NOTE

Once the stream ends then automatically the status gets updated from active to idle and again if the stream starts then it changes to active. This happens till the stream duration is within the limits.

  • The status gets updated to disabled if the duration limit reaches.
  • The stream will no longer be accessible after it is disabled.

createdAt: It displays the UTC date-time when the live stream is created.


enableRecording: This value indicates whether the live stream is being recorded. When it is set to true, the system will record the live stream, allowing it to be saved and accessed later. By default, the system will return true in the response, meaning that all live streams will be recorded automatically.

Recording live streams is beneficial for creating archived content, allowing users to replay the stream later, or providing access to those who missed the live event. If you don’t want recording after your livestream ends you can configure this value to false. So that recording functionality will be disabled for live streams.

playbackId:It is an array of playback ids for a live stream. playbackId in FastPix's Live Stream API work just like those for a video media. They allow you to do things like play live stream , grab thumbnails from a video, or make timeline hover previews with your player.

SrtPlaybackStreamId: A unique identifier used to reference and manage a specific SRT (Secure Reliable Transport) playback stream.

SrtPlaybackSecret: A secret key used to authenticate and secure access to the SRT playback stream.


Step 4: Start broadcasting

FastPix supports live streaming using the RTMPS and SRT protocol, widely compatible with various broadcasting software, hardware, and mobile applications.

To start live streaming, you or your users need software capable of pushing an RTMPS or SRT stream. This software will be configured using the Stream Key obtained earlier, along with FastPix's RTMPS or SRT Server URL.

How to stream using SRT?


📘

PLEASE NOTE

SRT is particularly effective when streaming over long distances or across different geographical regions, as it handles network jitter and packet loss much better than traditional protocols.


RTMPS server URL: rtmps://live.fastpix.io:443/live

SRT server URL: srt://live.fastpix.io:778

The above URLs are the standard entry points to stream live with FastPix. This is compatible with almost every streaming applications and services.

Here's how to stream using OBS :



The software you use for broadcasting will guide you on how to start and stop an RTMPS session. Once you begin the session, the software will send live video to FastPix. At that point, the live stream status changes to active, showing that it's receiving the RTMPS stream and ready to play using the Playback ID.


Live streaming webhooks

The moment someone begins streaming video and the live stream status changes, your application can respond using Webhooks. FastPix will send different related events. Depending on what kind of user experience you're aiming for, your application might take benefit from some of these events or might not if these events are not that relevant.


WebhookDescription
video.live_stream.createdA new live stream has been created. Broadcasters possessing a stream key can commence transmitting their encoder feed to this particular live stream.
video.live_stream.preparingStatus indicates that the live stream is being initialized and set up. During this phase, the system is validating inputs and allocating resources before going live.
video.live_stream.connectedThe live stream is in a "connected" status for video live streaming, confirming that an encoder has established a successful connection to it.
video.live_stream.recordingThe live stream's video recording is now in progress.
video.live_stream.activeThe live stream is currently marked as "active," signifying that it is presently "live" and actively broadcasting.
video.live_stream.disconnectedWhen the stream is stopped, causing the encoder to become disconnected.
video.live_stream.idleThe live stream enters an "idle" state as there is no ongoing streaming activity.
video.media.createdThis event is triggered when a live stream gets recorded and a new media has been successfully created as video-on-demand. Use this to notify your system when media is available in the platform.
video.live_stream.updatedThe live stream has been either updated, or the stream key for this livestream has been reset.
video.live_stream.deletedThe live stream has been deleted.


Step 4: Playback live stream

To watch a live stream, use the unique PLAYBACK_ID you received when setting up the live stream, along with stream.fastpix.io, to get the URL for playback using HTTP Live Streaming (HLS).


https://stream.fastpix.io/{PLAYBACK_ID}.m3u8

If you wish to playback the live stream in FastPix player by integrating into your development project, you can use the below JavaScript SDK to install via CDN.

To install via npm (Node Package Manager) click here .


<script src="https://cdn.jsdelivr.net/npm/@fastpix/player@1.0.1/dist/player.js"></script>

<fp-player
  stream-type="live-stream"
  playback-id="{playbackId}"
  primary-color="#F5F5F5"
  accent-color="#5D09C7"
  secondary-color="#000000"
/>

For step-by-step guidance on integrating with our video player, refer to the playback guide .

Once everything is set up, you can also integrate FastPix Data into your player to keep track of how the playback is performing.


Step 5: Stop stream broadcasting

Streamers can stop the broadcast software to disconnect from the FastPix servers. If any reconnect_window time was given as input and the time runs out, then the live stream will change its status to idle.

Please note that, live streams automatically gets disconnected after 12 hours. For any specific scenarios or requirements where you need more than 12 hours live streams - Please contact us.


API endpoints to handle Live stream functions


FastPix has the following endpoints that helps you to broadcast live:

API endpointRequest typeDescription
Create a new streamPOSTCreates a new live stream
Get all live streamsGETFetches all the available live streams
Get stream by IDGETFetches a particular live stream by its ID
Delete a streamDELETEDeletes a stream using live stream ID
Update a streamPATCHUpdates few parameters of a live stream
Get stream playback IDGETFetches playback Id of a live stream
Create a simulcastPOSTCreates a simulcast for a specific livestream
Delete a simulcastDELETEDelete’s a particular simulcast of a livestream
Get a specific simulcast of a stream GETFetches a particular simulcast of a livestream
Update a specific simulcast of a streamPUTEnable or disable a specific simulcast