Video playback and RTSP streaming in Unity¶
The Media Blocks SDK .NET ships a ready-to-import .unitypackage that brings video file playback and live RTSP / IP camera streaming into Unity 6 on Windows x64. Import it, press Play, and video renders into a Unity RawImage.
To install the package, see Install the Media Blocks SDK in Unity. This guide focuses on how the integration works and how to use the two bundled samples.
AI coding agents: use the VisioForge MCP server
Building this with Claude Code, Cursor, or another AI coding agent? Connect to the public VisioForge MCP server at https://mcp.visioforge.com/mcp for structured API lookups and verified code examples.
The full SDK is available — the samples are just a starting point
The package bundles the complete Media Blocks SDK .NET. The two included scenes (SimplePlayer and RTSPViewer) are examples to get you running quickly — your scripts have access to the entire Media Blocks API: capture and multiple source types, decoders and encoders, audio/video processing and effects, mixing and compositing, recording to file, and network streaming output. Build whatever pipeline your app needs. See the Media Blocks SDK .NET documentation for the full block catalog.
Samples¶
The package ships two ready scenes under Assets/Scenes/. Open one in the Project window (double-click it — do not stay on the empty default scene) and press ▶ Play:
- Play a media file — the
SimplePlayerscene, local video file playback. - View an RTSP camera — the
RTSPViewerscene, live RTSP / IP camera stream.
The RawImage looks empty until you press Play
The video texture is created at runtime, so the RawImage is blank (white) in edit mode. That is expected — nothing is drawn until the pipeline starts.
How rendering works¶
Two shared helpers handle setup and rendering for you, so each player script is just the Media Blocks pipeline:
VisioForgeEnvironment.Configure()runs automatically before the first scene loads and prepares the bundled native runtime — you don't manage any native dependencies or paths.VisioForgeEnvironment.InitializeSdk()initializes the SDK once. Call it before you build a pipeline (the sample players call it inStart()).- Each player builds a pipeline ending in a
BufferSinkBlock(VideoFormatX.RGBA); itsOnVideoFrameBufferevent hands video frames toVisioForgeVideoView. VisioForgeVideoViewuploads each frame into a UnityTexture2Don the main thread and applies the aspect mode, so the video shows up in yourRawImage. You don't write any texture code — just attach it (the sample players do this for you).
Editor lifecycle¶
The SDK initializes once per process and is reused across Play/Stop sessions in the Editor. Two points follow from that:
- Keep Disable Domain Reload on so re-entering Play mode reuses the initialized SDK. With it off, the Editor can hang when leaving Play mode.
- The sample players dispose only the per-play pipeline on Stop (
StopAsync) and intentionally do not shut the whole SDK down — keep that pattern in your own scripts.
If you hit instability after a script recompile, restart the Editor.
Frequently Asked Questions¶
Do I get the full Media Blocks SDK, or only playback?¶
The full SDK. The two sample scenes are starting points; your scripts have access to the entire Media Blocks SDK .NET API — capture, multiple source types, decoders and encoders, audio/video processing and effects, mixing and compositing, recording to file, and network streaming.
Can I render video into my own UI instead of the sample scenes?¶
Yes. Add a RawImage, attach MediaBlocksPlayer (file) or RTSPViewerPlayer (RTSP), or build your own pipeline and feed a BufferSinkBlock into VisioForgeVideoView. The texture upload, aspect handling, and flip are handled for you.
See Also¶
- Install the Media Blocks SDK in Unity — full setup, step by step
- Play a media file in Unity — the file-playback sample
- View an RTSP camera in Unity — the live RTSP / IP camera sample
- Media Blocks SDK .NET overview — the full block catalog and pipeline guide
- RTSP streaming guide — RTSP across the VisioForge .NET SDKs
- IP camera brands directory — tested camera URLs and settings