Smooth Video (Experimental)
Warning
This is an experimental feature.
This feature allows video playback to be perfectly smooth by not dropping or duplicating frames and presenting frames at the same rate at the display refresh rate.
This is particularly important for very large video walls where a single glitch in playback can be very noticable.
Limitations
- This feature only works on Windows and uses the Media Foundation API.
- Hap/NotchLC codecs are not supported
Setup
To use this feature:
- Add the text
AVPROVIDEO_SUPPORT_BUFFERED_DISPLAY
toEdit > Project Settings > Player > Scripting Define Symbols
. You can also enableDeveloper Mode
in theGlobal Section
of theMediaPlayer
component, and then tick theSupport Buffered Display
option. Now a new
Frame Selection
option will be available in theMediaPlayer
component . Set this toElapsed Time Vsynced
.Ensure that vsync is enabled in your application (
Edit > Project Settings > Quality
). In the Unity editor make sure it's also enabled in the Game View.- Ensure that your display vsync rate is a perfect multiple of your media frame rate. For example a display that is 60 FPS is fine for media that is 60 or 30 FPS.
- For best results your video shouldn't contain audio, but if they do then the audio may slightly ahead of the video. In this case you can enable the option
Use Audio Delay
to counteract this. - Don't run any scripts etc that delay the main thread, otherwise sync may be lost
Note
In the Unity editor it is difficult to achieve perfect playback. For best results play using a standalone IL2CPP build (ideally with full-screen mode set to exclusive).
How it works
- When the video loads it will being playing internally (pre-roll) and buffer those frames.
- Once pre-roll is complete the video can begin playback.
- Scripted logic selects which frame to display from the collection of buffered frames, based on vsync rate, Unity dropping frames etc.
- Meanwhile the buffers are continued to be filled up ahead of what is being displayed
- As long as the buffers are used and filled at the same rate, smooth playback should continue.
Debugging
We added some monitors to help understand how the buffers are logic are performing:
The Buffers
section shows the health of the buffers. For best results Buffered Frames
should be at least 4 and Free Frames
should be at least 3.
It can be difficult to spot dropped or duplicated frames, so the Presentation Quality
section tries to detect these and give you an overview on the smoothness.