s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationMediaVideo
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Media
Media

Video

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 compatibility
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.

VideoWriter is editor-only and is created through EditorUtility.CreateVideoWriter() (in the Editor namespace); its constructor is internal.

var writer = EditorUtility.CreateVideoWriter( "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();

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-04-22. Read it rendered on the official docs.

More in Media

Audio
Media
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.