Skip to content

SRT Reader

Overview

SRT Reader is a module within Mcaster that receives publications via the SRT (Secure Reliable Transport) protocol or captures streams from other servers via SRT. The module provides reliable video stream transmission with minimal latency and automatic recovery of lost packets.

Operating Principles

Receiving Publications

The module can receive SRT streams from external sources:

  • Publication — receiving streams from encoders or other servers
  • Capture — connecting to remote SRT servers
  • SPTS Support — working with Single Program Transport Stream

SRT Protocol

  • Reliability — automatic recovery of lost packets
  • Security — built-in encryption using passphrase
  • Low latency — optimized for live video
  • Adaptability — automatic adjustment to network quality

Configuration

Basic Setup for Receiving Publications

stream input-srt {
  input publish://;
  srt_publish {
    port 5912;
    latency 40;
  }
}

Configuration Parameters

Parameter Description Required Example
input publish:// Allows publication to stream Yes publish://
port Port for receiving SRT publication Yes 5912
latency Latency in milliseconds No 40
passphrase Encryption key No mysecretkey

Advanced Configuration

stream secure-srt {
  input publish://;
  srt_publish {
    port 5913;
    latency 60;
    passphrase "mysecretkey123";
  }

  # Additional settings
  buffer_size 8192;
  timeout 5000;
}

Stream Capture Configuration

stream capture-srt {
  input srt://remote-server:5912?passphrase=mysecretkey;
  output rtmp://server/live/captured;
}

SRT Options

passphrase

  • Purpose: Encryption key for stream protection
  • Requirement: Must be identical on both ends of connection
  • Format: String of arbitrary length
  • Recommendation: Use complex keys for security

latency

  • Purpose: Buffer latency configuration
  • Behavior: Affects stability but not critical for operation
  • Values: Usually 20-200 milliseconds
  • Default: 40 milliseconds

Publication Testing

Sending Stream via FFmpeg

# Publishing local file
ffmpeg -re -i input.mp4 -c copy -f mpegts srt://localhost:5912

# Publishing from camera
ffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -preset ultrafast -tune zerolatency -f mpegts srt://localhost:5912

# Publishing with passphrase
ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://localhost:5912?passphrase=mysecretkey"

Sending Stream from Another Server

# From another mcaster
ffmpeg -re -i input.mp4 -c copy -f mpegts srt://mcaster-server:5912

# From OBS Studio
# Configure SRT Output in OBS with address mcaster-server:5912

Monitoring

SRT-Specific Parameters

Round Trip Time (RTT)

{
  "stats": {
    "input": {
      "srt": {
        "rtt": 25.5  // Round Trip Time in milliseconds
      }
    }
  }
}
  • Description: Total delay for feedback
  • Normal value: 10-50 ms
  • Problematic value: >100 ms
  • Action: Check network quality when RTT is high

Real Latency

{
  "stats": {
    "input": {
      "srt": {
        "latency": 35.2  // Real latency in milliseconds
      }
    }
  }
}
  • Description: Actual latency on receiving side
  • Variability: Changes due to packet losses
  • Normal value: 20-80 ms
  • Monitoring: Track value stability

Retransmitted Packets

{
  "stats": {
    "input": {
      "srt": {
        "retransmitted_packets": 15  // Number of retransmitted packets
      }
    }
  }
}
  • Description: Number of packets sent again
  • Normal value: 0-50 packets per minute
  • Problematic value: >100 packets per minute
  • Cause: Poor network quality

General MPEGTS Reader Metrics

{
  "stats": {
    "input": {
      "packets_received": 125000,
      "packets_lost": 5,
      "bitrate": 5000000,
      "fps": 25.0
    }
  }
}

Usage Examples

Simple Publication

stream live_channel {
  input publish://;
  srt_publish {
    port 5912;
    latency 40;
  }
  output rtmp://server/live/stream;
}

Secure Publication

stream secure_channel {
  input publish://;
  srt_publish {
    port 5913;
    latency 60;
    passphrase "complex_secret_key_2024";
  }
  output rtmp://server/live/secure;
}

Multiple Streams

# Stream 1
stream channel_1 {
  input publish://;
  srt_publish {
    port 5912;
    latency 40;
  }
  output rtmp://server/live/ch1;
}

# Stream 2
stream channel_2 {
  input publish://;
  srt_publish {
    port 5913;
    latency 40;
  }
  output rtmp://server/live/ch2;
}

Transcoder Integration

stream transcoded_srt {
  input publish://;
  srt_publish {
    port 5914;
    latency 50;
  }

  transcoder {
    video {
      codec h264;
      bitrate 5000k;
    }
    audio {
      codec aac;
      bitrate 128k;
    }
  }

  output rtmp://server/live/transcoded;
}

Troubleshooting

Connection Issues

Cannot Connect to Port

  1. Check port availability — ensure port is not occupied
  2. Check firewall — allow incoming connections
  3. Check configuration — ensure settings are correct
  4. Check module logs for errors

High RTT

  1. Check network quality between client and server
  2. Increase latency for stabilization
  3. Check server load
  4. Consider using CDN

Frequent Packet Retransmissions

  1. Check network stability
  2. Reduce stream bitrate
  3. Check encoder settings
  4. Monitor internet connection quality

Diagnostic Commands

# Check port availability
netstat -tuln | grep 5912

# Connection test
telnet localhost 5912

# Network traffic monitoring
tcpdump -i any -n port 5912

# Check SRT metrics
curl -X GET "http://localhost:8080/api/stream_get?name=input-srt"

Configuration Recommendations

Optimal Latency Values

  • Stable network: 20-40 ms
  • Unstable network: 60-120 ms
  • Satellite connection: 200-500 ms
  • Mobile network: 100-200 ms

Security

  • Use complex passphrases — minimum 16 characters
  • Regularly change keys — every 30-90 days
  • Restrict port access — use firewall
  • Monitor connections — track suspicious activity

Performance

  • Sufficient bandwidth — minimum 2x stream bitrate
  • Stable internet connection — to minimize losses
  • Encoder optimization — configure for SRT
  • Resource monitoring — CPU, memory, network

Critical Parameter Monitoring

  • stats.input.srt.rtt — network quality
  • stats.input.srt.retransmitted_packets — connection stability
  • stats.input.srt.latency — real latency

Conclusion

SRT Reader provides reliable and secure video stream transmission with minimal latency. The module supports both receiving publications and capturing streams, making it a universal solution for various broadcasting scenarios. Built-in monitoring and diagnostics allow efficient management of transmission quality and quick resolution of emerging issues.