menu_bookDocumentation

Video - s&box Media Documentation

calendar_today May 5, 2026 schedule ~1 min read person patrickjr verified 50

Video

s&box can decode and play video files for cutscenes, UI elements, or in-world displays.

VideoPlayer

The VideoPlayer decodes video and exposes frames as a Texture:

CodecContainersNotes
VP9.webm, .mp4Good compatibility
AV1.webm, .mp4Best compression
WebP.webpSupports transparency
H.264.mp4Windows only
CSHARP
var player = new VideoPlayer();
player.OnLoaded += () => Log.Info( $"Loaded {player.Width}x{player.Height}" );
player.Play( FileSystem.Mounted, "videos/intro.webm" );

Streaming

Stream from URLs:

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

Using the Texture

VideoPlayer.Texture updates each frame:
CSHARP
// UI panel background
panel.Style.SetBackgroundImage( player.Texture );

// Material texture
material.Set( "Texture", player.Texture );

Audio

Audio settings on the Audio accessor:

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

VideoWriter

Record gameplay to video:

CSHARP
var writer = new VideoWriter();
writer.Open( "output.webm", width, height );

// Each frame
writer.WriteFrame( renderTexture );

// Finish
writer.Close();

Performance

  • Video decoding is hardware-accelerated when possible
  • Large videos can impact frame time
  • Consider resolution vs quality tradeoff
Was this helpful?