Overview

Foundry Virtual Tabletop includes built-in technology to allow for audio/video (A/V) conferencing between all of the players in your game. The WebRTC framework used is called simple-peer, and relies on direct peer-to-peer connections to establish audio and video conferencing, and leverages the inherent infrastructure in Foundry VTT to do so.

This article will cover the steps necessary to set up A/V integration using a self-signed certification, the A/V Configuration menu and its various options and a technical explanation of A/V integration for users interested in a more detailed understanding of the system.

Video conferencing can consume a significant amount of bandwidth. If your upload speed is relatively low, you may wish to consider alternate services for video conferencing while running your games. This can be understandably inconvenient if the purpose of getting Foundry VTT was to contain your video and audio chat and have it display as an overlay- use of third party relay servers can help mitigate some of the network usage, but the best option if you have insufficient upload speed to support video conferencing is to host Foundry VTT through a third party service.

Enabling A/V Chat Integration

The fastest way to set up Audio/Video integration is via a self-signed SSL certificate. Creating your own SSL certificate is easy and more secure than not having an SSL certificate, but is not the most secure option available. This setup will serve most users well without issue, but an optional, more complex, higher security route is available via the SSL and HTTPS article.

Step 1: Creating a Self-Signed Certificate

  1. Go to: https://www.selfsignedcertificate.com/
  2. Enter localhost as the server name, and click generate.
  3. Download the cert and key files, saving them somewhere you can easily find them.

Action 2: Configure Foundry VTT to use this certificate

  1. Copy the certificate and the private key files you downloaded to your FVTT's Config directory.
  2. Enter their file names in the SSL Certificate and SSL Private Key fields in the Configuration menu from within Foundry VTT.

Action 3: Enable A/V integration in Foundry VTT

  1. From the Audio/Video Configuration menu within a loaded game world select the Audio/Video Conferencing Mode you want to use, and click Save Changes.

When using a self-signed certificate, most browsers will warn users that they are entering an unsecured site when they visit it for the first time and periodically after that. Users may need to used advanced configuration to allow their browsers to accept self-signed certificates, and will need to click on the "Advanced" button and then "Proceed" after reloading the site to accept the certificate.

A/V Configuration

Audio Visual Configuration
The Audio/Video Configuration application.

From within the Foundry app, the AV Configuration panel is accessible from the Settings sidebar within your active World. This allows you to customize the A/V broadcast mode (including enabling or disabling it), configure a custom signalling or relay server, and designate your preferred webcam and microphone hardware. If no microphone or webcam appear in this list, the most likely cause is that the devices are already in use by another program. Refreshing the screen (ctrl+f5) after you have released the devices from other programs using them should resolve this.

Audio/Video Conferencing Mode
Used to select whether you wish to disable A/V, transmit audio only, video only, or use both audio and video conferencing.
Voice Broadcasting Mode
The method by which your microphone activates to transmit audio. If always enabled, the microphone will continually broadcast. Voice activation will activate the microphone only when it crosses a threshold of volume. Push to talk uses the assigned push-to-talk hotkey to trigger microphone activation while it is held down.
Push-to-Talk/Mute key:
Assign the keyboard key to be used to trigger Push to Talk. To assign a key, simply click into the input field and then press the keyboard key you wish to use. By default this is assigned to the backtick key: `
Video Capture Device
A list of available devices which can be used as a video source for video conferencing, choose your camera or video source here. If this list is empty or reads "Unknown Device", you may need to grant permission to use the camera for your browser, or to verify that no other programs are currently using the capture device.
Audio Capture Device
A list of available devices which can be used as an audio source, choose your microphone or audio source here. If this list is empty or reads "Unknown Device", you may need to grant permission to use the camera for your browser, or to verify that no other programs are currently using the capture device.
Audio Output Device
A list of available devices which FVTT should send audio-video to. By default, this is 'Default Device' which uses whichever device your OS uses as a primary sound output, but you can choose a specific output if you wish to output to headphones but not speakers, for example. (Please note that Firefox users will not see this option unless they have set media.setsinkid.enabled to true in their about:config).

For details on the configuration of the Server tab of A/V Configuration, please see discussion of relay and signalling servers below.

How A/V Integration Works

Peer to Peer AV
Audio/Video connections when peer-to-peer is functioning correctly.
AV Relay Server
A/V Relying upon the relay server when peer-to-peer connections are unavailable.

Audio-Video communication through Foundry VTT primarily uses peer-to-peer connections, which requires that all users (not just the server host) need to have UDP ports allowed through software firewalls and routers in order to properly connect.

The first diagram on the right shows an example of a peer-to-peer conference, all users are connected to one another. Notice how the connections are to one another, but do not actually pass through the Relay server. When one user speaks, they transmit audio and video directly to all other users in the game, and all other users receive that information directly without the user of a relay server. If the connections are not configured correctly, participants in the A/V conference may be unable to connect to each other and audio and video streams between those users will fail to appear.

The second diagram on the right demonstrates the way the Foundry VTT relay server works. If a user cannot establish a peer-to-peer connection with another user, the Foundry VTT relay server is used to pass information between those users instead. Notice that the GM as well as Player 1 and Player 2 are still connected through peer-to-peer connections, but Player 3 and Player 4 are only connected via the relay server. In this case, when the user speaks, they transmit audio and video to the relay server, which then re-transmits the stream to that user instead. This process places far more network overhead on the Foundry VTT server.

To allow connections through the FVTT Relay server, the following ports must be opened on any firewall software that is in use and a port forwarding rule must be created to direct these connections to your hosted server:

UDP primary port: 33478
UDP port range: 49152-65535

If you are self hosting Foundry VTT and you have not done any port-forwarding, then the relay server may not work correctly for you. If you are using a server such as AWS or DigitalOcean or any other VPS service, then as long as the proper ports are allowed access to the server, you shouldn't have any issues.

You can customize the signalling and relay servers used for A/V functionality within the AV Config application accessed through the Settings Sidebar. The Foundry VTT server also acts as a signalling server so there is nothing to do here either. As long as you and your users can connect to FVTT, you are good to go. FVTT also has support for using an external signalling server if you wish and the GameMaster can configure it in the Audio/Video Configuration window under the Server tab. Using a custom server might be preferred if you are having trouble setting up a relaying server, though you can also configure a custom relay server to use directly.

More about Simple-Peer

Simple-Peer is a free, open-source, concise API for WebRTC which facilitates the creation of peer-to-peer data, video, and audio calls in node.js.

You can read more about Simple-Peer here: https://github.com/feross/simple-peer

More about WebRTC

WebRTC (Web Real-Time Communication) is an open-source project geared toward enabling high-quality real-time conferencing applications for browsers and mobile platforms. It was initially released in 2011, and allows audio and video communication to work inside web pages through direct peer-to-peer communication, eliminating the need to install plugins or download additional software.

You can read more about WebRTC here: https://webrtc.org/

Using a Jitsi Server

Jitsi is a free, open-source voice conferencing platform which can be used to provide an alternative to peer-to-peer WebRTC communications. By using Jitsi, all users connect to the Jitsi server instead of connecting directly to each other. This often removes the necessity for port forwarding (if the Jitsi server is not hosted on your computer.) Through use of third party modules it is possible to WebRTC in Foundry Virtual Tabletop to use a Jitsi server for better performance and stability. Please see the following resources for more information about using Jitsi:

  1. The Jitsi WebRTC module.
  2. The excellent Jitsi Server Setup Instructions created by community member Solfolango.

API References

To interact with AV programmatically, consider using the following API concepts:

AVMaster - The Master Audio/Video controller instance

AVConfig- The Audio/Video Conferencing Configuration Sheet

CameraViews - The Camera UI View