Ninja Docs
  • What is VDO.Ninja?
    • How does it work
    • Use cases
    • Why use VDO.Ninja over other solutions?
    • Sponsor ❤
  • Getting started
    • VDO.Ninja basics
    • What are stream IDs?
    • The power of the URL parameter
    • Multi-Person Chat
    • Rooms
    • Even higher quality video
    • Mobile phone camera into webcam
    • Cheat sheet of basic parameters
  • Steve's helper apps & tools
    • Electron Capture
      • Documentation
    • Social Stream Ninja
      • Documentation reference
    • Meshcast.io
    • Caption.Ninja
    • Raspberry.Ninja
      • Documentation
    • Mixer App
    • WHIP and WHEP tooling
    • Versus.cam
    • Speed Test
    • Comms
    • Teleprompter Tool
    • LUT maker for color grading
    • Native mobile app versions
    • VDO Applications
    • Tech Demonstrations
    • Invite Link Generators
    • Community contributed tools
    • Mic test
  • Guides
    • Cheat Sheets
    • Common questions re: Rooms
    • Video bitrate for push/view links
    • Video bitrate in rooms
    • How to get permanent links
    • Basic hotkeys
    • MIDI, API and WebHID support
    • Hardware-accelerated video encoding
    • Audio Filters & Bitrate
    • Options to record streams
    • External guides and how-tos
    • How to lock the resolution
    • How to use VDO.Ninja as a webcam for Google Hangouts, Zoom, and more
    • How to capture without browser sources
    • How to control bitrate/quality
    • How to selectively allow access
    • Stream Scheduling and Promotion
    • How to send the audio/video output of one OBS to another OBS using VDO.Ninja
    • How to mirror a video while Full-Screen - For iPads and Teleprompters
    • How to capture an application's audio
    • How to control VDO.Ninja with Touch Portal
    • How to publish from OBS into VDO.Ninja
    • How to screen share your iPhone/iPad
    • How to get iPhones to output 1080p Videos
    • How to stream into Zoom without OBS
    • How to connect a smartphone to computer via USB
    • How to edit an invite after sending it
    • How to get highest video quality (for an interview)
    • How to stream 4K video using VDO.Ninja
    • How to get lowest audio latency possible
    • How to share webcam from inside OBS
    • How to publish to Facebook Live
    • How to embed VDO.Ninja into a site with iFrames
      • Detecting User Joins / Disconnects
    • How to use the green screen just locally
    • How to connect a GoPro to VDO.Ninja
    • How to install RaspNinja on Jetson
    • How to transfer guests to other rooms
    • How to set up a simple chat room
    • How to screen share in 1080p
    • How to control PowerPoint remotely with VDO.Ninja
    • How to improve quality of the native app
    • How to stream transparent video
    • Recommended OBS WHIP settings
    • How to use VDO.Ninja on a website
    • Keep Mic Active in Background on Android Browser
    • PlayStation or Xbox to VDO.Ninja
    • Enabling WebRTC Sources in OBS
    • Picking the right microphone
    • Set Up Proper Lighting
    • System requirements for streaming
    • From OBS to VDO.Ninja using WHIP
    • Deploy your own Meshcast-like service
    • Windows TTS Audio Capture Methods for OBS
    • Syncing USB audio with VDO.Ninja -> OBS Virtual Camera
  • Advanced Options (URL Parameters)
    • Most common Parameters
      • &push
      • &quality
      • &videodevice
      • &audiodevice
      • &effects
      • &label
      • &meshcast
      • &view
      • &videobitrate
      • &audiobitrate
      • &codec
      • &novideo
      • &noaudio
      • &showlabels
      • &room
      • &director
      • &proaudio
      • &scene
      • &roombitrate
      • &password
      • &broadcast
    • Setup Parameters
      • &push
      • &room
      • &password
      • &hash
      • &e2ee
      • &label
      • &labelsuggestion
      • &permaid
      • &group
      • &groupview
      • &groupaudio
      • &datamode
      • &audiooutput
      • &sink
      • &audiodevice
      • &videodevice
      • &vdo
      • &device
      • &miconly
      • &miconlyoption
      • &safemode
      • &autostart
      • &easyexit
      • &webcam
      • &webcam2
      • &screenshare
      • &screenshare2
      • &website
      • &fileshare
      • &intro
      • &host
      • &tips
      • &welcome
      • &welcomeb64
      • &welcomeimage
      • &hangupmessage
      • &humb64
      • &groupmode
      • &audience
    • Camera Parameters
      • &whitebalance
      • &exposure
      • &saturation
      • &sharpness
      • &contrast
      • &brightness
    • Video Parameters
      • &blind
      • &quality
      • &width
      • &height
      • &aspectratio
      • &contenthint
      • &mediasettings
      • &noscale
      • &fps
      • &maxframerate
      • &effects
      • &effectvalue
      • &imagelist
      • &avatar
      • &fullscreen
      • &showpreview
      • &minipreview
      • &minipreviewoffset
      • &largepreview
      • &nopreview
      • &hideguest
      • &videomute
      • &ptz
      • &webp
      • &webpquality
      • &scale
      • &viewwidth
      • &viewheight
      • &dpi
      • &sharper
      • &codec
      • &h264profile
      • &buffer
      • &buffer2
      • &fadein
      • &broadcast
      • &directoronly
      • &showonly
      • &novideo
      • &nodirectorvideo
      • &slideshow
      • &zoom
    • Video Bitrate Parameters
      • &outboundvideobitrate
      • &maxvideobitrate
      • &limittotalbitrate
      • &controlroombitrate
      • &roombitrate
      • &maxbandwidth
      • &videobitrate
      • &totalscenebitrate
      • &totalroombitrate
      • &totalbitrate
      • &zoomedbitrate
      • &optimize
    • Audio Parameters
      • &proaudio
      • &stereo
      • &mutespeaker
      • &deafen
      • &noaudioprocessing
      • &audiodevice
      • &echocancellation
      • &audiogain
      • &autogain
      • &compressor
      • &denoise
      • &distort
      • &equalizer
      • &limiter
      • &lowcut
      • &noisegate
      • &noisegatesettings
      • &audiocontenthint
      • &audiolatency
      • &micdelay
      • &mute
      • &automute
      • &outboundaudiobitrate
      • &inputchannels
      • &monomic
      • &audiooutput
      • &sink
      • &volume
      • &volumecontrol
      • &audiobitrate
      • &vbr
      • &mono
      • &noaudio
      • &nodirectoraudio
      • &panning
      • &sync
      • &samplerate
      • &channels
      • &channeloffset
      • &playchannel
      • &ptime
      • &maxptime
      • &minptime
      • &audiocodec
      • &dtx
      • &nofec
    • Mixer/Scene Parameters
      • &solo
      • &view
      • &include
      • &exclude
      • &layout
      • &activespeaker
      • &activespeakerdelay
      • &order
      • &slots
      • &fakeguests
      • &randomize
      • &cover
      • &43
      • &portrait
      • &square
      • &forceviewerlandscape
      • &animated
      • &manual
      • &locked
      • &poster
      • &hideplaybutton
      • &motiondetection
      • &scene
      • &scenetype
      • &autoadd
      • &hiddenscenebitrate
      • &preloadbitrate
      • &waitimage
      • &waitmessage
      • &waittimeout
      • &viewslot
    • Settings Parameters
      • &language
      • &remote
      • &controlobs
      • &allowedscenes
      • &stats
      • &sticky
      • &clearstorage
      • &disablehotkeys
      • &showlist
      • &nopush
      • &hidehome
      • &hidetranslate
      • &clock
      • &clock24
      • &timer
      • &powerpoint
      • &widget
      • &token
      • &transcribe
      • &signalmeter
      • &batterymeter
      • &consent
      • &prompt
      • &hands
      • &notify
      • &r2d2
      • &directorchat
      • &maxconnections
      • &maxviewers
      • &chunked
      • &retransmit
      • &rampuptime
      • &sensor
      • &sensorfilter
      • &postimage
      • &postinterval
      • &slot
      • &closedcaptions
      • &nocaptionlabels
      • &enhance
      • &bitratecutoff
      • &cutscene
      • &statsinterval
      • &keyframerate
      • &maxpublishers
      • &showconnections
      • &obsfix
      • &streamlabs
      • &getfaces
      • &nochunked
    • Buttons and Control Bar Parameters
      • &autohide
      • &controlbarspace
      • &nosettings
      • &nomicbutton
      • &nospeakerbutton
      • &novideobutton
      • &nofileshare
      • &screensharebutton
      • &nohangupbutton
      • &chatbutton
      • &bigbutton
      • &fullscreenbutton
      • &nowebsite
      • &hands
      • &videocontrols
      • &nocontrols
      • &forcecontrols
    • Design Parameters
      • &label
      • &showlabels
      • &fontsize
      • &style
      • &bgimage
      • &showall
      • &meterstyle
      • &cleanoutput
      • &cleanish
      • &css
      • &base64css
      • &js
      • &base64js
      • &mirror
      • &nomirror
      • &flip
      • &rotatewindow
      • &structure
      • &color
      • &blur
      • &border
      • &bordercolor
      • &rounded
      • &margin
      • &darkmode
      • &lightmode
      • &background
      • &chroma
      • &transparent
      • &nocursor
      • &favicon
      • &headertitle
      • &rotate
      • &grid
      • &hideheader
      • &hidemenu
      • &tally
      • &tallyoff
      • &cleanviewer
      • &obsoff
      • &pip
      • &pipall
      • &pipme
    • Director Parameters
      • &director
      • &codirector
      • &blindall
      • &cleandirector
      • &hidesolo
      • &hidecodirectors
      • &minidirector
      • &orderby
      • &queue
      • &rooms
      • &broadcasttransfer
      • &showdirector
      • &slotmode
      • &previewmode
      • &novice
      • &layouts
      • &maindirectorpassword
      • &totalroombitrate
      • &limittotalbitrate
      • &notify
      • &mutespeaker=0
      • &showconnections
      • &widget
      • &pausepreview
    • Screen-share Parameters
      • &screensharestereo
      • &screenshare
      • &screenshare2
      • &screenshareaec
      • &screenshareautogain
      • &screensharecursor
      • &screensharedenoise
      • &screensharefps
      • &screensharehide
      • &screenshareid
      • &screensharelabel
      • &screensharequality
      • &screensharecontenthint
      • &screenshareaspectratio
      • &screensharetype
      • &smallshare
      • &screensharevideoonly
      • &suppresslocalaudio
      • &prefercurrenttab
      • &selfbrowsersurface
      • &systemaudio
      • &displaysurface
      • &screensharebutton
      • &screensharebitrate
      • &sharperscreen
      • &sspaused
    • Recording Parameters
      • &record
      • &autorecord
      • &autorecordlocal
      • &autorecordremote
      • &recordcodec
      • &pcm
      • &recordmotion
      • &chunked
    • Guest queuing Parameters
      • &queue
      • &screen
      • &hold
      • &holdwithvideo
      • &queuetransfer
    • Meshcast Parameters
      • &meshcast
      • &meshcastaudiobitrate
      • &meshcastbitrate
      • &meshcastcodec
      • &mcscreensharebitrate
      • &mcscreensharecodec
      • &meshcastscale
      • &meshcastcode
      • &nomeshcast
    • WHIP Parameters
      • &whipout
      • &whipview
      • &whipoutcodec
      • &whipoutaudiobitrate
      • &whipoutvideobitrate
      • &whipoutscale
      • &whipoutscreensharecodec
      • &whipoutscreensharebitrate
      • &cftoken
      • &svc
    • Mobile Parameters
      • &facing
      • &forcelandscape
      • &forceportrait
      • &forceios
      • &notios
      • &flagship
      • &mobile
      • &notmobile
      • &app
    • API & MIDI Parameters
      • &api
        • API reference
        • API reference - AI Generated
        • Client (node) event example
      • &pie
      • &midi
      • &midiin
      • &midiout
      • &midiremote
      • &midichannel
      • &mididevice
      • &midioffset
      • &mididelay
      • &datamode
      • &postapi
    • TURN & STUN Parameters
      • &turn
      • &stun
      • &addstun
      • &icefilter
      • &proxy
      • &relay
      • &secure
      • &tcp
      • &tz
    • Parameters added in Version 24
    • Complete List of Parameters in v26
    • Upcoming Parameters
    • Other Parameters
  • Releases
    • v24
    • v23 🌱
    • v22 👑
    • v21 ❤️
    • v20 🎁
    • v19 🚀🤯
      • v19.1 - 19.4
    • v18
      • v18.3
    • v17
    • v16
      • v16.3
      • v16.4
    • v15
    • v14
    • v13
      • v13.4
    • v12
    • v10
    • v8
  • Updates
    • Updates - VDO.Ninja
    • Updates - Social Stream & Chat Overlay
      • Updates - Social Stream Standalone App
    • Updates - Electron Capture App
    • Updates - Raspberry.Ninja
    • Updates - Versus.cam
    • Updates - Mixer App
    • Updates - WHIP/WHEP
    • Updates - Native mobile apps
    • Updates - Caption.Ninja
    • Updates - Meshcast.io
    • Updates - Speed Test
    • Updates - Comms
    • Updates - Miscellaneous
  • Development Progress
  • Help!
    • Fail safes and Backups
    • Privacy and security details
      • VDO.Ninja Terms of Service
      • VDO.Ninja Privacy Policy
    • Project Contact Info
    • Where can I report a bug?
    • Where can I get support?
    • Feature Requests
    • Logos and media assets
    • What does VDO stand for?
  • Common errors and known issues
    • Can't screen capture certain games
    • ATEM not working with Firestick
    • Very old iPhone support
    • Can't select audio output on iOS
    • Screen-share is just a black video
    • Mic audio dropping out
    • Loss of audio when OBS minimized
    • Known issues
    • Echo or feedback issues
    • Works on WiFi but not on 4G
    • Can't capture an application's audio when screen-sharing
    • Can't load camera both in OBS and VDON
    • Can't select a camera lens on mobile
    • No video in OBS, just an "Add camera" button
    • Audio over VDO.Ninja isn't working
    • Loading circle shows in OBS or browser
    • Appearing then disappearing guest
    • Can't auto-start screen sharing
    • Audio Clicking / Popping / Distortion
    • Can't share my screen
    • Nothing shows up in OBS
    • Already in use or claimed errors
    • Blue spinning window
    • Cursor shows trailing or artifacting
    • Packet Loss
    • Overheating
    • Audio is delayed in OBS
    • vMix High CPU
    • OBS Virtual Camera has low FPS
    • Virtual camera not working on Mac
    • Mic stops on MacOS when OBS opens
    • Video stream looks corrupted
    • Video freezes mid-stream
    • Webcam freezes after a time
    • Is the VDO.Ninja server down?
    • Hosted your own TURN server?
    • Can't screen-share from certain devices
    • Cursor shows when screen-sharing
    • Getting “Overconstrained" Camera Error
    • Autoplay doesn't work in Chrome or vMix v77
    • Low frame rates
    • Black borders around the video in OBS
    • Mic's volume keeps changing
    • Enable Camera / Microphone permissions
    • FPS drop if app not in focus
    • Surround sound error when screen sharing with USB headset
    • Relay candidate being selected
    • Camera works in Safari; not Chrome
    • Robotic Audio Distortion
    • Can't load camera from non-SSL host
    • Camera on macOS doesn't show?
    • Can't screen share Adobe Lightroom
    • Decklink support?
    • iOS audio stops during phone calls
    • Can't turn off echo-cancellation on macOS
    • Video lag grows over time
    • Can't connect unless via VPN
    • Improving vMix performance
  • Platform specific issues
    • Android
    • macOS
    • iOS (iPhone/iPad)
    • Firefox
    • Opera GX
  • Useful Links
  • FAQ
  • Sponsor ❤
  • Edit this documentation
Powered by GitBook
On this page
  • Using MediaMTX with VDO.Ninja for Scalable Broadcasting
  • Why Use MediaMTX with VDO.Ninja?
  • Prerequisites
  • Deployment Guide: MediaMTX
  • Integrating MediaMTX with VDO.Ninja
  • Using the &mediamtx Parameter in VDO.Ninja: A Simple Guide
  • Conclusion

Was this helpful?

  1. Guides

Deploy your own Meshcast-like service

A detailed guide on how to deploy MediaMTX, a ready-to-use media server, that offers Meshcast-like functionality

Okay, here is a detailed guide on how to deploy MediaMTX, a ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server, to use with VDO.Ninja's Meshcast-like functionality. This guide is written for beginners and advanced users alike, aiming to make the setup process as straightforward as possible.

Using MediaMTX with VDO.Ninja for Scalable Broadcasting

This guide will walk you through deploying MediaMTX (formerly rtsp-simple-server) as a self-hosted media server to enhance your VDO.Ninja experience, particularly for large audiences. By using MediaMTX, you can create a setup similar to VDO.Ninja's Meshcast feature, offloading the encoding and distribution of your streams to a dedicated server. This significantly reduces the load on your computer and network, enabling you to host more viewers and maintain a high-quality stream.

Why Use MediaMTX with VDO.Ninja?

VDO.Ninja, by default, uses peer-to-peer connections for video and audio transmission. While this works great for small groups, it can become a bottleneck when dealing with a larger audience. Each viewer adds to the upload bandwidth and encoding burden on the sender's machine.

Meshcast is a feature in VDO.Ninja designed to solve this scalability issue. It acts as an intermediary server (SFU or Selective Forwarding Unit) that receives a single stream from the broadcaster and then redistributes it to multiple viewers. This greatly reduces the load on the broadcaster.

MediaMTX allows you to replicate the functionality of Meshcast using your own server. By integrating MediaMTX with VDO.Ninja, you achieve:

  • Scalability: Handle a large number of viewers without overloading your computer or network.

  • Reduced Load: The broadcaster only needs to encode and upload the stream once to the MediaMTX server.

  • Improved Performance: Viewers receive a smoother, more stable stream as the server handles distribution.

  • Cost Savings: While Meshcast is a free service offered by VDO.Ninja, using your own MediaMTX server can be more cost-effective, especially if you already have a server or prefer using a VPS.

  • Control: You have full control over your media server, including its configuration and security.

  • Flexibility: MediaMTX supports various protocols beyond WebRTC (WHIP/WHEP), including SRT, RTSP, RTMP, and HLS, opening up possibilities for broader integration.

Prerequisites

Before we begin, make sure you have the following:

  • A server or computer: You'll need a machine to host the MediaMTX server. This can be:

    • Local machine (Windows, macOS, or Linux): Suitable for testing or small audiences, but you'll need to configure your router for port forwarding, which is not covered in this tutorial.

    • Virtual Private Server (VPS): Ideal for larger audiences and production environments. Recommended for best performance and reliability.

  • Domain name (Optional but Highly Recommended): While not strictly necessary, a domain name (e.g., yourdomain.com) simplifies configuration and makes your setup more user-friendly. It's also highly recommended for using free SSL certificates (for HTTPS). Using an IP address directly is not optimal, although you can still have VDO.Ninja generate SSL keys for you if you opt to use an IP address only.

  • Basic command-line knowledge: You'll need to be comfortable using the command line or terminal for your operating system.

  • VDO.Ninja: You should be familiar with the basic usage of VDO.Ninja.

Deployment Guide: MediaMTX

This guide will cover the deployment of MediaMTX on:

  • Linux Server (using a VPS like Vultr)

  • Windows

  • macOS

1. Deploying on a Linux Server (VPS)

Choosing a VPS Provider

Several VPS providers offer affordable and reliable services. Some popular options include:

For this guide, we'll use Vultr as an example, but the steps are similar for other providers.

Setting up your Vultr VPS

  1. Deploy a new server:

    • Choose Cloud Compute.

    • Select Optimized Cloud Compute for CPU & Storage Technology. High Frequency is the recommended option here.

    • Choose a server location that's geographically close to your target audience for optimal latency.

    • For Server Image, choose a Linux distribution. Ubuntu 22.04 LTS is a good option for its stability and long-term support. Debian 11 or 12 are also popular choices for use with Mediamtx.

    • Select a Server Size based on your expected audience size. For a small to medium-sized audience, the $6/month plan should be sufficient to start.

    • Enable IPv4 if needed, or leave it disabled for IPv6 only.

    • Give your server a Hostname (e.g., mediamtx-server).

    • Click Deploy Now.

  2. Wait for the server to be provisioned: This usually takes a few minutes.

  3. Connect to your server: Once the server is running, Vultr will display its IP address. You'll need to connect to it using SSH:

    • Linux/macOS: Open your terminal and run: ssh root@your_server_ip (replace your_server_ip with the actual IP address).

Installing MediaMTX

Once you're connected to your server via SSH, follow these steps:

  1. Update the package list:

    Bash

    sudo apt update
  2. Install MediaMTX:

    Bash

    wget https://github.com/bluenviron/mediamtx/releases/latest/download/mediamtx_linux_amd64.tar.gz
    tar -xf mediamtx_linux_amd64.tar.gz
    sudo mv mediamtx /usr/local/bin/
    sudo mv mediamtx.yml /usr/local/etc/
  3. Run MediaMTX:

    Bash

    mediamtx

    To configure Mediamtx to auto-start on boot, you can setup a service.

    Bash

    sudo curl -s https://raw.githubusercontent.com/bluenviron/mediamtx/main/mediamtx.service --output /etc/systemd/system/mediamtx.service
    sudo systemctl daemon-reload
    sudo systemctl start mediamtx
    sudo systemctl enable mediamtx

Setting up a Domain Name (Optional but Recommended)

If you'd like to avoid using IP addresses directly and enable HTTPS, you'll want to use a domain name.

  1. Purchase a domain name: You can buy affordable domain names from registrars like:

  2. Configure DNS records:

    • After purchasing your domain, go to your domain registrar's DNS settings.

    • Create an A record that points your domain (or a subdomain like media.yourdomain.com) to your Vultr server's IP address. If you're using IPv6, create an AAAA record instead.

Enabling HTTPS (Optional but Recommended)

HTTPS is crucial for security and WebRTC compatibility in many browsers. If you only have an IP address available and no domain name, you can set up Mediamtx to generate and serve the SSL keys for you. This is outlined in the Mediamtx documentation.

If you have a domain name, here's how to set up free SSL certificates using Let's Encrypt with Cloudflare:

Using Cloudflare for Free SSL

  1. Add your domain to Cloudflare: Follow the instructions to add your website to Cloudflare. This usually involves changing your domain's nameservers to Cloudflare's nameservers. You will need to update your domain name's DNS records at your domain registrar, replacing them with the ones provided to you by Cloudflare.

  2. Enable SSL/TLS:

    • In your Cloudflare dashboard, go to the SSL/TLS tab.

    • Choose the Full (strict) encryption mode. This ensures secure communication between your server and Cloudflare, as well as between Cloudflare and your visitors. If this fails, you can try other SSL options available.

  3. Configure your Nginx configuration file to redirect HTTP traffic to HTTPS. Or, you can enable the "Always Use HTTPS" option under SSL/TLS -> Edge Certificates.

  4. Enable proxyProtocol under the http element of your Mediamtx.yml file.

Cloudflare will now automatically issue and renew SSL certificates for your domain.

If you are unable to use Cloudflare, you can also try using CertBot.

  1. Install Certbot and Nginx plugin:

    Bash

    sudo apt install certbot python3-certbot-nginx
  2. Obtain and install a certificate:

    Bash

    sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

    Replace yourdomain.com and www.yourdomain.com with your actual domain name. Follow the prompts to configure HTTPS.

  3. Automatic renewal: Certbot automatically sets up a cron job or systemd timer to renew your certificates before they expire.

Opening Firewall Ports

Your VPS likely has a firewall enabled. You need to open the following ports for MediaMTX to work correctly:

  • 8889 (WHEP/WHIP): Used for WebRTC streaming.

  • 8554 (RTSP): Used for RTSP connections.

  • 1935 (RTMP): Used for RTMP connections.

  • 8888 (HLS): Used for HTTP Live Streaming.

  • 80 (HTTP) Used for Let's Encrypt renewals if not using Cloudflare or for general HTTP access.

  • 443 (HTTPS) Used for secure HTTPS access.

Here's how to open these ports using ufw (Uncomplicated Firewall), a common firewall management tool:

Bash

sudo ufw allow 8889/tcp
sudo ufw allow 8554/tcp
sudo ufw allow 1935/tcp
sudo ufw allow 8888/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

If using iptables instead, you can use these commands:

Bash

sudo iptables -I INPUT -p tcp --dport 8889 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 8554 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 1935 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT
sudo netfilter-persistent save

If your VPS provider has a built-in firewall, you might need to open these ports in their control panel as well.

2. Deploying on Windows

Installing MediaMTX on Windows

  1. Extract the archive: Extract the downloaded ZIP file to a folder of your choice (e.g., C:\mediamtx).

  2. Run MediaMTX: Open a Command Prompt or PowerShell window, navigate to the extracted folder, and run:

    Bash

    .\mediamtx.exe

Opening Firewall Ports (Windows)

You'll need to allow MediaMTX through the Windows Firewall:

  1. Open Windows Defender Firewall: Search for "Windows Defender Firewall" in the Start menu and open it.

  2. Click on "Advanced settings" on the left sidebar.

  3. Inbound Rules:

    • Click on "Inbound Rules" in the left pane.

    • Click on "New Rule..." in the right pane.

    • Select "Port" and click "Next".

    • Select "TCP" and enter the following ports in "Specific local ports": 8889, 8554, 1935, 8888, 80, 443 (you can add them as a comma-separated list). Click "Next".

    • Choose "Allow the connection" and click "Next".

    • Select the network profiles (Domain, Private, Public) for which you want to apply this rule. For home use, "Private" is usually sufficient. Click "Next".

    • Give the rule a name (e.g., "MediaMTX Ports") and click "Finish".

  4. Outbound Rules: You might also need to create outbound rules if you have a strict firewall configuration. Repeat the steps above, but select "Outbound Rules" instead of "Inbound Rules" in step 3.

Allowing connections through your router's firewall

You may need to manually forward ports 8889, 8554, 1935, 8888, 80, 443 to the IP address of your local PC. You will need to refer to your router's documentation on how to do this, as this process will vary based on make and model.

3. Deploying on macOS

Installing MediaMTX on macOS

  1. Extract the archive: Open a Terminal window and use the tar command to extract the archive:

    Bash

    tar -xf mediamtx_vX.Y.Z_darwin_amd64.tar.gz

    (Replace mediamtx_vX.Y.Z_darwin_amd64.tar.gz with the actual filename).

  2. Move MediaMTX (Optional): You can move the mediamtx executable to a more convenient location, like /usr/local/bin/:

    Bash

    sudo mv mediamtx /usr/local/bin/
  3. Run MediaMTX: Open a Terminal window and run:

    Bash

    mediamtx

Opening Firewall Ports (macOS)

macOS has a built-in firewall called pf. Here's how to open ports:

  1. Edit the pf configuration file:

    Bash

    sudo nano /etc/pf.conf
  2. Add the following lines to the end of the file:

    pass in proto tcp from any to any port 8889
    pass in proto tcp from any to any port 8554
    pass in proto tcp from any to any port 1935
    pass in proto tcp from any to any port 8888
    pass in proto tcp from any to any port 80
    pass in proto tcp from any to any port 44
  3. Save the file and exit the editor (Ctrl+X, then Y, then Enter).

  4. Load the new pf rules:

    Bash

    sudo pfctl -f /etc/pf.conf
  5. Enable pf:

    Bash

    sudo pfctl -e

Allowing connections through your router's firewall

You may need to manually forward ports 8889, 8554, 1935, 8888, 80, 443 to the IP address of your local PC. You will need to refer to your router's documentation on how to do this, as this process will vary based on make and model.

Integrating MediaMTX with VDO.Ninja

Now that your MediaMTX server is up and running, it's time to integrate it with VDO.Ninja.

Understanding the Logic

VDO.Ninja uses the &mediamtx parameter to connect to your MediaMTX server. Here's how it works:

  1. &mediamtx Parameter: When a guest joins a VDO.Ninja room with the &mediamtx parameter in their URL, VDO.Ninja interprets it as the address of your MediaMTX server.

  2. WHIP Output: VDO.Ninja automatically constructs the WHIP (WebRTC-HTTP ingestion Protocol) endpoint based on the &mediamtx value and the stream ID. The guest's browser will publish their stream to this WHIP endpoint on your MediaMTX server.

  3. WHEP URL Sharing: The guest's browser shares the WHEP (WebRTC-HTTP Egress Protocol) URL of their stream (also hosted on your MediaMTX server) with other participants in the VDO.Ninja room via the data channel.

  4. WHEP Playback: Viewers in the VDO.Ninja room receive the WHEP URL and use it to play the stream from the MediaMTX server instead of directly from the guest via a peer-to-peer connection.

Using the &mediamtx Parameter in VDO.Ninja: A Simple Guide

The &mediamtx parameter is your key to connecting VDO.Ninja with your MediaMTX server, allowing you to create a scalable and efficient streaming setup. Here's how you use it and what you need to know:

What it Does

The &mediamtx parameter tells VDO.Ninja where your MediaMTX server is located. When a guest joins your VDO.Ninja room with this parameter, their browser will send their video and audio stream directly to your MediaMTX server instead of relying solely on peer-to-peer connections. Your MediaMTX server then handles distributing the stream to viewers.

How to Use It

You add the &mediamtx parameter to the end of the VDO.Ninja guest invite link, followed by the address of your MediaMTX server.

Formatting Options

Here's the breakdown of how to format the &mediamtx value:

  1. Basic Domain Name:

    • Format: &mediamtx=yourdomain.com

    • What it does: If you provide just a domain name (without http:// or https:// and without a port number), VDO.Ninja makes the following assumptions:

      • It assumes you want to use HTTPS (secure connection).

      • It assumes your MediaMTX server is running on the standard HTTPS port for WHIP/WHEP, which is 8889.

      • It assumes the top level domain is .com if you do not specify it. &mediamtx=mymediatxserver will be treated as &mediamtx=mymediatxserver.com.

    • Example: &mediamtx=mymediaserver.com will connect to https://mymediaserver.com:8889/.

    • Recommendation: This is the simplest and recommended way if you've set up your domain with HTTPS and are using the default WHIP/WHEP port (8889).

  2. Domain Name with Different Top-Level Domain:

    • Format: &mediamtx=yourdomain.xyz (or any other valid TLD)

    • What it does: Similar to the basic format, but allows you to specify a different top-level domain.

      • Assumes HTTPS.

      • Assumes the standard WHIP/WHEP port 8889.

    • Example: &mediamtx=stream.live will connect to https://stream.live:8889/.

  3. Specifying a Port:

    • Format: &mediamtx=yourdomain.com:port

    • What it does: If your MediaMTX server is running on a port other than 8889 for WHIP/WHEP, you need to specify it.

      • Assumes HTTPS if not specified.

    • Example: &mediamtx=yourdomain.com:8890 will connect to https://yourdomain.com:8890/.

  4. Specifying HTTP or HTTPS:

    • Format: &mediamtx=http://yourdomain.com or &mediamtx=https://yourdomain.com

    • What it does: You can explicitly specify whether to use HTTP or HTTPS.

    • Example: &mediamtx=http://yourdomain.com:8889 will connect to http://yourdomain.com:8889/.

    • Recommendation: Always prefer HTTPS for security.

  5. Using an IP Address:

    • Format: &mediamtx=123.45.67.89 or &mediamtx=123.45.67.89:port

    • What it does: You can use your server's IP address instead of a domain name.

      • Assumes HTTPS and port 8889 if not specified.

    • Example: &mediamtx=192.168.1.100:8890 will connect to https://192.168.1.100:8890/.

    • Note: Using IP addresses directly is generally not recommended for production because you cannot get a typically trusted SSL certificate without a domain name. If you do use an IP address, consider specifying the port, and configuring HTTPS via Mediamtx's automatic SSL generation.

  6. Using localhost (for local testing):

    • Format: &mediamtx=localhost or &mediamtx=localhost:port

    • What it does: If you're testing MediaMTX locally on your own computer, you can use localhost.

      • Assumes HTTP and port 8889 if not specified.

    • Example: &mediamtx=localhost:8890 will connect to http://localhost:8890/.

Important Notes

  • HTTPS is Highly Recommended: Always strive to use HTTPS for secure communication. WebRTC often requires HTTPS in many browsers.

  • Default Port: If you don't specify a port, VDO.Ninja assumes the default WHIP/WHEP port for MediaMTX, which is 8889.

  • Stream ID: VDO.Ninja automatically generates a unique stream ID for each guest. You don't need to specify this in the &mediamtx parameter.

  • Room Name: VDO.Ninja uses the room name as part of the path for WHIP/WHEP on the MediaMTX server.

Summary Table

Format
Assumed Protocol
Assumed Port
Notes

yourdomain.com

HTTPS

8889

Assumes .com TLD. Simplest and recommended if using HTTPS and default port.

yourdomain.xyz

HTTPS

8889

Allows for specifying a different TLD.

yourdomain.com:port

HTTPS

Specified

Use if your MediaMTX WHIP/WHEP server is on a non-default port.

http://yourdomain.com

HTTP

8889

Explicitly uses HTTP. Not recommended for production.

https://yourdomain.com

HTTPS

8889

Explicitly uses HTTPS. Recommended.

123.45.67.89

HTTPS

8889

Uses IP address. Assumes HTTPS and default port. Less ideal for production due to SSL limitations.

123.45.67.89:port

HTTPS

Specified

Uses IP address with a specific port. Consider specifying HTTPS if needed, and configuring SSL via Mediamtx's automatic SSL generation.

localhost

HTTP

8889

For local testing only. Assumes HTTP and default port.

localhost:port

HTTP

Specified

For local testing with a specific port.

By following these guidelines, you can correctly format the &mediamtx parameter and ensure that your VDO.Ninja guests connect seamlessly to your MediaMTX server. Remember that using a domain name with HTTPS is the most secure and user-friendly approach for most scenarios.

Usage Example

Here's a step-by-step example of how to use MediaMTX with VDO.Ninja:

  1. Guest URL: A guest joining a VDO.Ninja room would use a URL like this:

    https://vdo.ninja/?room=YourRoomName&mediamtx=yourdomain.com

    or

    https://vdo.ninja/?room=YourRoomName&mediamtx=your_server_ip:8889

    Replace YourRoomName with your actual room name, yourdomain.com with your domain name, or your_server_ip with your server's IP address. If you haven't set up a domain, just use the IP.

  2. Director's View: The director (or other viewers) can view the stream as usual in the VDO.Ninja room. They don't need to add any special parameters to their URL. VDO.Ninja will automatically handle the playback from the MediaMTX server.

  3. Direct WHEP Playback (Optional): If you want to play the stream directly from the MediaMTX server (outside of VDO.Ninja), you can use the WHEP URL. It will look like this:

    https://yourdomain.com:8889/YourRoomName/YourStreamID/whep

    or

    https://your_server_ip:8889/YourRoomName/YourStreamID/whep

    You can obtain YourStreamID from the VDO.Ninja interface or the URL of the guest's browser window.

    You may need to provide this URL manually if you want to play the stream in a separate player that supports WHEP.

Configuration Tips

  • Audio: If you want to ensure stereo audio, even when using MediaMTX, you might need to use the &stereo parameter in the guest's URL. The code you provided suggests that setting session.stereo=3 might force stereo, but you'll need to confirm this behavior.

  • Stream ID: The streamID in the WHIP/WHEP URLs is automatically generated by VDO.Ninja. It's usually a random string. You can find the stream ID in the guest's VDO.Ninja URL or in the VDO.Ninja interface.

  • Security:

    • HTTPS: Always use HTTPS (SSL) for your MediaMTX server to protect the stream and user data.

    • Authentication: Consider configuring authentication for your MediaMTX server if you need to restrict access to your streams. Refer to the MediaMTX documentation for details on how to set up authentication.

  • Performance:

    • Server Resources: Monitor your server's CPU, memory, and bandwidth usage to ensure it can handle the load. Upgrade your server if necessary.

    • Network Latency: Choose a server location that's geographically close to your audience to minimize latency.

    • Bitrate: Adjust the bitrate of your stream in VDO.Ninja based on your available bandwidth and the desired quality.

  • Troubleshooting:

    • Firewall: Double-check that your firewall (both on the server and your local machine if testing locally) is configured to allow the necessary ports.

    • Domain Propagation: If you're using a domain name, make sure the DNS records have fully propagated.

    • MediaMTX Logs: Check the MediaMTX logs for any errors or warnings.

    • Browser Console: Use your browser's developer console (usually by pressing F12) to look for any errors related to WebRTC or network requests.

Conclusion

Deploying MediaMTX and integrating it with VDO.Ninja provides a powerful and scalable solution for broadcasting to larger audiences. By offloading the stream distribution to a dedicated server, you can significantly improve the performance and stability of your VDO.Ninja streams.

This guide has covered the essential steps for setting up MediaMTX on Linux, Windows, and macOS, including VPS deployment, domain name configuration, HTTPS setup, and firewall configuration. It has also explained how to use the &mediamtx parameter in VDO.Ninja to connect to your MediaMTX server and leverage its capabilities.

Remember to tailor the configuration to your specific needs and environment. Monitor your server's performance and adjust settings as necessary to ensure a smooth and high-quality streaming experience for your viewers. With a little bit of setup, you can take your VDO.Ninja broadcasts to the next level with the power of MediaMTX!

PreviousFrom OBS to VDO.Ninja using WHIPNextWindows TTS Audio Capture Methods for OBS

Last updated 4 months ago

Was this helpful?

Vultr: - Offers a wide range of plans and locations, starting at around $2.50/month (IPv6 only) or $3.50/month (IPv4). Their High-Frequency Compute options are recommended for better performance.

DigitalOcean: - Another popular choice with user-friendly interface and good performance.

Linode: - Known for its excellent customer support and robust infrastructure.

AWS Lightsail: - Amazon's offering, integrating well with other AWS services.

Sign up for a Vultr account: Visit and create an account.

Windows: You can use an SSH client like PuTTY ().

If you're on a different architecture, like ARM, check the for the correct package.

Namecheap: - Often has great deals on domains, especially for the first year. You can get domains for as low as $1/year.

Porkbun: - Also offers competitive pricing and user-friendly interface.

DNS changes can take some time to propagate (up to 48 hours, but usually much faster). You can use tools like to check the propagation status.

Create a Cloudflare account: Go to and sign up for a free account.

Download MediaMTX: Go to the MediaMTX releases page on GitHub () and download the latest release for Windows (e.g., mediamtx_vX.Y.Z_windows_amd64.zip).

Download MediaMTX: Go to the MediaMTX releases page on GitHub () and download the latest release for macOS (e.g., mediamtx_vX.Y.Z_darwin_amd64.tar.gz).

https://www.vultr.com/
https://www.digitalocean.com/
https://www.linode.com/
https://aws.amazon.com/lightsail/
https://www.vultr.com/
https://www.putty.org/
Mediamtx releases
https://www.namecheap.com/
https://porkbun.com/
https://www.whatsmydns.net/
https://www.cloudflare.com/
https://github.com/bluenviron/mediamtx/releases
https://github.com/bluenviron/mediamtx/releases