Skip to content

Instantly share code, notes, and snippets.

@mondain
Last active August 21, 2026 15:02
Show Gist options
  • Select an option

  • Save mondain/77cd461cf2a6f6a7caec8a2ade64be36 to your computer and use it in GitHub Desktop.

Select an option

Save mondain/77cd461cf2a6f6a7caec8a2ade64be36 to your computer and use it in GitHub Desktop.
SRT via OpenMOQ Publisher Examples

SRT via OpenMOQ Publisher Examples

Two examples are provided for SRT inter-operation, one uses a file and the other is more direct. Ensure that you update any servers URL's or namespaces to match your setup.

Example 1 - File ingest

This example uses a file ingest read by ffmpeg which provides an SRT listener endpoint for openmoq-publisher to call; the caller uses the json configuration file.

  1. Create your json file; example path and name: /tmp/srt_caller.json
{
  "srt_caller": [
    {
      "id": "cam1",
      "srt": {
        "mode": "caller",
        "host": "127.0.0.1",
        "port": 9000,
        "latency_ms": 120
      },
      "mpegts": {
        "auto_detect_program": true,
        "program_number": null,
        "video_pid": null,
        "audio_pid": null
      },
      "cmaf": {
        "fragment_on_keyframe": true,
        "empty_moov": true,
        "default_base_moof": true,
        "separate_moof_per_track": true,
        "target_fragment_duration_ms": 1000
      }
    }
  ]
}
  1. Start ffmpeg as the SRT listener using file ingest
ffmpeg -hide_banner -stream_loop -1 -re -i fragmented.mp4 \
  -map 0:v:0 -map 0:a:0 \
 -r 30 -g 60 -keyint_min 60 -sc_threshold 0 -bf 0 \
  -c:a aac -b:a 128k -ar 48000 -ac 2 \
  -f mpegts "srt://0.0.0.0:9000?mode=listener&pkt_size=1316"
  1. Start the publisher which uses the json file
./build/openmoq-publisher --live-source srt --srt-config /tmp/srt_caller.json --transport webtransport --endpoint https://moq-relay1.red5.net:4433/moq --namespace live/srt --draft 16 --publish-catalog

Example 2 - SRT direct

  1. Create your json file; example path and name: /tmp/srt_caller_direct.json
{
  "srt_caller_direct": [
    {
      "id": "read_teste",
      "srt": {
        "mode": "caller",
        "host": "127.0.0.1",
        "port": 8890,
        "latency_ms": 200
      },
      "mpegts": {
        "auto_detect_program": true,
        "program_number": null,
        "video_pid": null,
        "audio_pid": null
      },
      "cmaf": {
        "fragment_on_keyframe": true,
        "empty_moov": true,
        "default_base_moof": true,
        "separate_moof_per_track": true,
        "target_fragment_duration_ms": 1000
      }
    }
  ]
}
  1. Start the publisher which uses the json file
./build/openmoq-publisher --live-source srt --srt-config /tmp/srt_caller_direct.json --transport webtransport --endpoint https://moq-relay2.red5.net:4433/moq --namespace live/srt --draft 16 --publish-catalog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment