# Millicast video streaming

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-d2dccdc2933a1ffa51fb3609974a299285dc5a03%2Fbc4c6696-4275-4e90-a780-654effda1e79.png?alt=media" alt=""><figcaption><p>Streaming within the experience</p></figcaption></figure>

{% hint style="info" %}
**In Review** - feature maturity not classified, documentation in progress and likely to change
{% endhint %}

### Overview <a href="#millicastvideostreaming-overview" id="millicastvideostreaming-overview"></a>

Millicast is a third-party streaming solution offered by [Dolby.io](http://dolby.io) which is an e2e solution for recording, encoding and showing live video streams in the experience.

### Basic setup <a href="#millicastvideostreaming-basicsetup" id="millicastvideostreaming-basicsetup"></a>

Follow the steps [here](https://docs.msquared.io/creation/unreal-development/features-and-tutorials/video-players/millicast-video-streaming/how-to-set-up-an-in-game-video-stream) to get a video feed running in-game.

### Multi-stream support <a href="#millicastvideostreaming-multi-streamsupport" id="millicastvideostreaming-multi-streamsupport"></a>

{% hint style="warning" %}
*<mark style="color:yellow;">We officially support</mark>* *<mark style="color:yellow;">**up to 2 streams**</mark><mark style="color:yellow;">. Running more than two is possible but we cannot ensure optimal performance. Going above performance guidelines can cause lower hardware clients to run slower and provide a below optimal experience.</mark>*
{% endhint %}

{% embed url="<https://www.youtube.com/watch?index=1&list=PLFpGM1qm9wJAPp1vLS4NuwJzEQZxv8HuE&v=XUQPlUlVfbs>" %}

### Advanced - Implement Millicast In Your Own Blueprint <a href="#millicastvideostreaming-advanced-implementmillicastinyourownblueprint" id="millicastvideostreaming-advanced-implementmillicastinyourownblueprint"></a>

{% embed url="<https://youtu.be/X2QU0SlKCuU>" %}

### Millicast Control Config <a href="#millicastvideostreaming-millicastcontrolconfig" id="millicastvideostreaming-millicastcontrolconfig"></a>

Your Stream Name and Account Id can be found on [Dolby.io](http://dolby.io)

Stream Url should be set to: <https://director.millicast.com/api/director/subscribe>

Example:

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-750056ef5c5651ffe4739fba5d198e5085970bac%2Fcdc446ce-8e32-4220-9023-8b9b4690e12c.png?alt=media" alt=""><figcaption></figcaption></figure>

### Screen Control <a href="#millicastvideostreaming-screencontrol" id="millicastvideostreaming-screencontrol"></a>

If you’re using BPM\_VideoPlayer instead, you may have to check your screen controls and make sure the “Millicast” option is selected.

### Configuring your stream <a href="#millicastvideostreaming-streamconfig" id="millicastvideostreaming-streamconfig"></a>

{% hint style="warning" %}
When streaming, you have to **select either vp8 or vp9** codecs. **h.264 is not supported by Unreal.**

Furthermore **RTMP and RTMPS are not supported**.
{% endhint %}

**OBS Output Tab**

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-40794f058f531637703dea204a10975ee757a4a0%2Foutput_tab.png?alt=media" alt=""><figcaption></figcaption></figure>

**Video and Audio Bitrate** will determine the amount of data per second which will be transferred to the client.

Note that bitrate numbers are Not an exact science, and the server will internally modulate this number to better fit the connection, so the resulting bitrate can be much higher than that.\
What we know is that those numbers will still influence the stream in some way. More of this in recommended settings.

**Encoder** is usually never changed. Has to be noted that using H264 currently has problems with Millicast for Unreal.

**Encoder Preset** can change the how quick the image gets encoded/decoded in expense of image quality.

#### OBS Video Tab <a href="#video-tab" id="video-tab"></a>

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-154846bcf640d5da00e6161bd3c7d12b3941e62f%2F47467ed8-3c58-4f4e-baaf-ede1054a87af.png?alt=media" alt=""><figcaption></figcaption></figure>

**Output (Scaled) Resolution** is the important one as it is the resolution the client will receive, scaled from the initial input.

**Downscale Filter** states how precise the scaled image will be when generated. Unless specific needs, a Bicubic should be fine.

**Common FPS Values** are the target frames per second the server will send to the clients. There is currently no point to go higher than 30 as the game instances we use are capped at 30 FPS. Also to note that this parameter highly influences performance.

### Recommended Settings <a href="#recommended-settings" id="recommended-settings"></a>

The following values are to be taken as an example, and to consider if the hardware to support is down to the level of a G6\_Half or lower budget.

Having multiple screens in the scene will add little performance loss. Most of Millicast performance cost is given by each data stream.

Other than the supported hardware, will depend on how many streams are intended to be used.\
Only the most influential parameters are named, the rest is at user choice:

Budget for pixels: as many as a resolution of 1920x1080

Budget for video bitrate: 4000

Common FPS Values: 30 or lower

#### Example with a single stream <a href="#example-with-a-single-stream" id="example-with-a-single-stream"></a>

Output (Scaled) Resolution: 1920x1080

Video Bitrate: 4000

Audio Bitrate: 192

Common FPS Values: 30

#### Example with two streams (for each stream) <a href="#example-with-two-streams-for-each-stream" id="example-with-two-streams-for-each-stream"></a>

Output (Scaled) Resolution: 1280x720

Video Bitrate: 2000

Audio Bitrate: 192

Common FPS Values: 30

### Monitor Settings From Client <a href="#monitor-settings-from-client" id="monitor-settings-from-client"></a>

From a non-shipping client build it is possible to print the stats for the current active Millicast streams in the scene by using the command:

`M2.Millicast.PrintStreamsStats`

which, for each active stream, will print the following info:

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-8672dd0721df1a519b946091daa5608628c5cfdd%2F70f53a73-a6ee-4c3f-85b4-2702a32d322b.png?alt=media" alt=""><figcaption></figcaption></figure>

FAQ

Q: I want to stream pre-recorded video, should I use millicast?

A: No, please use the lightweight [Streaming Video Player](https://docs.msquared.io/creation/unreal-development/features-and-tutorials/video-players/streaming-video-player) instead.

Q: I have added multiple Millicast screens and the performance is poor, what should I do?

A: Performance will decrease with each additional video played in your world. Please re-consider if multiple Millicast Screens is an appropriate solution to your problem.

## Known Issues

### Blueprint Loaded Sublevels

The control panels used to control Millicast screens detect available screens in their `MorpheusBeginPlay`. This means that if you have Millicast screens in sublevels that are dynamically loaded, there are no guarantees their detection of available screens will happen after those assets have been loaded. To avoid this issue, ensure that all Millicast screens are in always loaded sublevels.

### Having multiple millicast controls

We recommend that you only have one Millicast control (e.g. `BPM_MillicastControl`) present in your level. Each control is able to control *all* Millicast screens present in your level, so updating one control panel will then immediately invalidate the values in any other control panels (whichever panel updates the most recently will be used as the source of truth in your level.)

Relatedly, when a new client joins the level, it will be a race which control panel's data ultimately is applied on their screen (if multiple have data set). So if multiple control panels are actively being used, different clients could end up seeing different millicast screens active.

### PIE with multiple clients

We have observed that millicast screens can misbehave in strange ways when using multiple PIE clients. This appears to be specific to having mulltiple clients in PIE, which doesn't happen for cooked or standalone clients.

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-32483420b7c84377d65622fde56ad9183b280c5d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
