Set up an SRT live streaming app using python SDK

July 11, 2025
10 Min
Live Streaming
Share
This is some text inside of a div block.
Join Our Newsletter for the Latest in Streaming Technology

Fun fact: NASA used SRT to stream from space. Turns out, it handles packet loss better than most conference Wi-Fi.

If you’re building a live video experience, for gaming, webinars, events, or something niche and want better latency, fewer dropouts, and real encryption, SRT is probably on your radar.

In this guide, we’ll show you how to get an SRT stream up and running using the FastPix Python SDK. You’ll handle auth, create a stream, go live with OBS or ffmpeg, and view your stream in a browser. Nothing fancy, just what you need to get it working.

What is SRT?  

SRT (Secure Reliable Transport) is a protocol built for low-latency streaming over unreliable networks. It's open-source, uses UDP, and has built-in recovery for packet loss and jitter.

Why it's useful:

  • Low latency: Real-time interaction feels real-time.
  • Network-friendly: Recovers from dropped packets and jitter without falling apart.
  • Encrypted: Streams are protected with AES by default.

It’s a solid alternative to RTMP, especially when you care about quality or reliability.

Why use a Python SDK for live streaming?

Live video isn’t just about pushing pixels, it’s about coordinating stream states, metadata, events, and edge cases. Without an SDK, you're often juggling raw API calls, brittle scripts, and manual configurations that don't scale.

Using a Python SDK streamlines this. You can automate stream creation, control playback behavior, and respond to events in real time, all from inside your own backend or tools. It’s especially useful when you want to build systems that react to what's happening in the stream, not just push it out.

Typical things you can do:

  • Trigger stream start/stop from scheduled tasks
  • Monitor stream health and fire alerts
  • Attach metadata or configure simulcasting dynamically

In short: it helps you build actual video features, not just duct-tape together infrastructure.

Why FastPix’s python SDK?

FastPix handles the lower-level video infrastructure, ingest, playback, simulcast, monitoring and exposes it through a clean, developer-focused Python SDK.

It supports:

  • Stateless auth with API tokens
  • On-demand stream creation and deletion
  • SRT ingest URLs out of the box
  • Playback URLs, simulcast config, and analytics hooks

The SDK is designed to plug into real apps, not toy demos. Whether you’re integrating with OBS or building custom admin tools.

What you’ll need before you start (Prerequisites)  

To get the stream flowing, make sure you’ve got a few essentials ready:

  • A FastPix account: Sign up to access the dashboard and API keys.
  • An API token: You’ll need both the Access Token ID and Secret Key from your dashboard.
  • Python 3.7 or higher installed, plus the FastPix Python SDK.
  • Some way to send video: OBS Studio or FFmpeg works great for pushing SRT.
  • Something to watch the stream: VLC, FFmpeg, or your own player for testing playback.
  • And a decent internet connection: Wired is best if you’re broadcasting live.

That’s it. With those in place, you’re ready to start building your first live stream with FastPix and SRT.

Step 1: Get your FastPix API token

To use the FastPix Python SDK, you’ll need an Access Token ID and a Secret Key.

Here’s how to generate them:

  1. Log in to your FastPix dashboard
  1. Go to Settings → Access Tokens
  1. Click Generate new token
  1. Name it something like srt-live-app, and give it Read + Write access to FastPix Video
  1. Copy both the Access Token ID and Secret Key and store them securely

You won’t be able to view the Secret Key again after this, if you lose it, you’ll have to generate a new one.

You’ll use these credentials to authenticate API requests and initialize the SDK in the next step. For more details, refer to the FastPix API documentation.

Step 2: Install the FastPix Python SDK

You’ll need Python 3.7+ to get started. To install the SDK, just run:

1pip install fastpix

To make sure everything installed correctly, pop into a Python shell and check the version:

1import fastpix 
2print(fastpix.__version__)

If that runs without errors, you're good to go. Let’s move on to authentication.

Step 3: Create a livestream with the Python SDK

Now let’s spin up an SRT livestream using the FastPix SDK. You’ll authenticate with your credentials and call the create_live_stream() method.

Here’s how it looks:

1from fastpix import FastPixClient 
2
3client = FastPixClient(username="your_username", password="your_password") 
4response = client.create_live_stream( 
5    playbackSettings={ 
6        "accessPolicy": "public" 
7    }, 
8    inputMediaSettings={ 
9        "maxResolution": "1080p", 
10        "reconnectWindow": 60, 
11        "mediaPolicy": "public", 
12        "metadata": { 
13            "livestream_name": "fastpix_demo_stream" 
14        } 
15    } 
16) 
17 
18print("Stream ID:", response["streamId"]) 
19print("SRT Secret Key:", response["srtSecretKey"]) 
20print("Status:", response["status"]) 
21print("Created At:", response["createdAt"]) 
22
23# Build the SRT and playback URLs 
24srt_url = ( 
25    f"srt://{response['srtPlaybackResponse']['host']}:" 
26    f"{response['srtPlaybackResponse']['port']}?streamid=" 
27    f"{response['srtPlaybackResponse']['streamId']}" 
28) 
29
30print("SRT URL:", srt_url) 
31playback_url = response["srtPlaybackResponse"]["playbackUrl"] 
32print("Playback URL:", playback_url) 

This gives you everything you need: the SRT ingest URL for your encoder (like OBS), and the playback URL to view the stream in a browser or custom player.

What the parameters mean

When creating a livestream, you’re passing in two main config blocks: playbackSettings and inputMediaSettings. Here's what they control:

playbackSettings

  • accessPolicy: Controls who can view the livestream. Use "public" for open access or "restricted" if you're gating playback (e.g. via token or auth headers).

inputMediaSettings

  • maxResolution: Limits the resolution of the incoming stream. Choose from "720p", "1080p", or "4k" depending on what your encoder sends.
  • reconnectWindow: The grace period (in seconds) FastPix will wait if your stream disconnects. For example, 60 means it’ll try to reconnect for a full minute before shutting down.
  • mediaPolicy: Sets the visibility of the recorded VOD (if enabled). "public" means the VOD can be accessed by anyone; "private" restricts access.
  • Metadata: Optional key-value pairs you can attach to the stream. Handy for tagging events ("livestream_name", "event_id", etc.) or adding tracking hooks.

Step 4: Configure your SRT encoder

With your stream created and credentials ready, it’s time to push live video using an encoder. You can use OBS Studio, FFmpeg, or anything that supports SRT.

SRT URL format

srt://live.fastpix.io:778?passphrase=<SRT Secret Key>&streamid=<Stream ID>


Swap in your actual secret key and stream ID from the API response.

Example: Using OBS Studio

  1. Open OBS and go to Settings → Stream
  1. Set Service to Custom
  1. Paste the full SRT URL into the Server field
  1. Leave Stream Key blank
  1. Set bitrate (e.g. 4000 Kbps for 1080p) and frame rate (e.g. 30 FPS)
  1. Click Apply and then Start Streaming

OBS will begin broadcasting to the FastPix SRT endpoint.

Example: Using FFmpeg

For CLI users, here’s how to push a stream:

bash

ffmpeg -re -i input_video.mp4 -c:v copy -c:a aac -f mpegts \
"srt://live.fastpix.io:778?passphrase=<SRT Secret Key>&streamid=<Stream ID>"

Tip: Always test your stream before going live. You can check status and metrics in the FastPix dashboard.

You can use any video file or device input. If you’re testing, start with a local MP4.

Tip: Always test your stream before going live. You can check status and metrics in the FastPix dashboard.

Step 5: Playback your SRT stream

Once your stream is live, you can test playback using either:

  • SRT (via VLC or FFmpeg)
  • HLS (for browser-based players like Video.js)

SRT playback URL format

srt://live.fastpix.io:778?streamid=play<Stream ID>&passphrase=<Playback Secret>

Replace <Stream ID> and <Playback Secret> with the values from your stream API response.

Option 1: FFmpeg / FFplay

Use this command to view your stream in real time via terminal:

ffplay -analyzeduration 1 -fflags -nobuffer -probesize 32 -sync ext \
"srt://live.fastpix.io:778?streamid=play<Stream ID>&passphrase=<Playback Secret>"

Option 2: VLC

  1. Open VLC  
  2. Go to Media → Open Network Stream    
  3. Paste your SRT playback URL    
  4. Click Play

Option 3: Web playback (HLS)

The API also returns an HLS playback URL, which works in most HTML5 players. Example with Video.js:

<video-js id="player" controls preload="auto">
  <source src="<HLS Playback URL>" type="application/x-mpegURL">
</video-js>

<script src="https://vjs.zencdn.net/7.20.3/video.min.js"></script>
<script>
  var player = videojs('player');
</script>

Just drop in your actual HLS URL from the API, and it’ll play in any browser that supports HLS.

Step 6: Simulcast to YouTube, Twitch, or Facebook

Need to go live on multiple platforms at once? FastPix can automatically convert your SRT stream to RTMPS and forward it to services like YouTube, Twitch, or Facebook.

Set it up via dashboard

1.     Open your stream in the FastPix dashboard

2.     Go to Simulcast → Add Target

3.     Enter the RTMPS URL and Stream Key from the platform (e.g. YouTube Studio)

4.     Click Save and toggle the target on

FastPix handles the rest, no need to re-encode or set up separate workflows.

Or do it programmatically with Python

You can also manage simulcast targets via the FastPix SDK:

response = client.live.add_simulcast_target(
    streamId="your_stream_id",
    target={
        "url": "rtmps://a.rtmps.youtube.com/live2",
        "streamKey": "your_youtube_stream_key",
        "metadata": {
            "platform": "youtube",
            "label": "Main YouTube Broadcast"
        }
    }
)

print("Simulcast target added:", response)

This let's you dynamically add, remove, or swap platforms based on app logic, useful for multi-event setups or user-configurable streams.

Step 7: Monitor and troubleshoot your livestream

Once you’re live, the FastPix dashboard gives you real-time visibility into stream health and viewer metrics. You can track things like packet loss, latency, and concurrent viewers, helpful for both debugging and performance tuning.

If something’s off, start here:

Stream not starting?
Check your SRT URL, Stream ID, and passphrase, typos are common. Also make sure your network allows outbound UDP traffic on port 778. If you’re using a cloud VM, double-check its firewall settings too.

Poor video quality?
Unstable connection? Drop your bitrate, 2500 Kbps is usually fine for 720p. Also make sure your encoder uses a 2-second keyframe interval. It helps with smoother playback and HLS compatibility.

Playback issues?
Verify the playback URL and SRT passphrase from your API response. If VLC is being stubborn, try ffplay to isolate the problem.

If you’re still stuck, consult the FastPix SRT playback guide or reach out via the dashboard, the support team knows their stuff.

A few tips to keep your streams clean

  • Use a wired connection whenever possible    
  • For 1080p, aim for 4000–6000 Kbps bitrate and 2s keyframes      
  • Never expose your access tokens or passphrases in logs or code      
  • Always test with a small audience before scaling to thousands    
  • FastPix automatically handles delivery at scale via CDN, so you don’t have to

Use case examples of using Python SDKs


1. Live event streaming

Running a virtual conference or webinar? You can use the FastPix SDK to spin up dedicated streams for each session, keynotes, panels, breakout rooms. Simulcasting lets you broadcast to platforms like YouTube and Facebook at the same time, while sessions are recorded automatically for later playback. It’s a solid setup for reaching both live and on-demand viewers with minimal overhead.

2. Gaming streams

If you’re building a gaming broadcast app or streaming gameplay directly, FastPix + SRT gives you the low-latency delivery needed to keep things responsive. Just hook up OBS with your SRT credentials, set the encoder for real-time interaction, and go live. You can simulcast to Twitch, track engagement through real-time analytics, and keep latency under control, even with network hiccups.

Bottom line

Got questions? Not sure if your setup will play nice with SRT?

Talk to us. We’ve worked with teams building everything from hackathon demos to full-scale streaming platforms. If you’re building something with live video, we’d love to hear about it,  and help you get it working, fast.

It's Free

Enjoyed reading? You might also like

Try FastPix today!

FastPix grows with you – from startups to growth stage and beyond.