s&box docs

Video

Decodes a video file or URL and exposes the current frame as a Texture.

VideoPlayer

Decodes a video file or URL and exposes the current frame as a Texture.

CodecContainersNotes
VP9.webm, .mp4
AV1.webm, .mp4Best compression and quality
WebP.webpSupports transparency
H.264.mp4Windows only via Media Foundation, not recommended
var player = new VideoPlayer();
player.OnLoaded += () => Log.Info( $"Loaded {player.Width}x{player.Height}" );
player.Play( FileSystem.Mounted, "videos/intro.webm" );

Streaming over HTTP/HTTPS is also supported:

player.Play( "https://example.com/stream.webm" );

VideoPlayer.Texture updates each frame and can be used anywhere a Texture is accepted.

panel.Style.SetBackgroundImage( player.Texture );
material.Set( "Texture", player.Texture );

Audio settings live on the Audio accessor:

player.Audio.Volume = 0.5f;
player.Audio.Position = WorldPosition;
player.Audio.TargetMixer = Mixer.FindMixerByName( "Music" );

VideoWriter

Encodes a sequence of RGBA frames into a video file. Used internally by the screen recorder.

CodecContainersNotes
VP9.webm, .mp4Best compatbility
AV1.webm, .mp4Best compression and quality
WebP.webpAnimated WebP, supports transparency

WebM supports transparency. The EncodingPreset on VideoWriter.Config controls speed vs quality: Fast for real-time recording, Balanced for general use, Quality for offline export.

var writer = new VideoWriter( "recordings/output.mp4", new VideoWriter.Config
{
    Width = 1920,
    Height = 1080,
    FrameRate = 60,
    Bitrate = 14,
    Codec = VideoWriter.Codec.AV1,
    Container = VideoWriter.Container.MP4,
    Preset = VideoWriter.EncodingPreset.Fast,
    AudioCodec = VideoWriter.AudioCodec.Opus,
} );

writer.AddFrame( rgbaBytes );

await writer.FinishAsync();

Referenced API

Canonical API pages mentioned in this guide.

Created at:
Updated at:

On this page