Skip to main content

Encoder

The Encoder plugin extends the base Window class with an EncoderWindow class, enabling real-time, low-latency hardware H264 encoding of rendered window content. This functionality provides a foundation for server-side rendering or VR/AR streaming by encoding the framebuffer directly into H264 format.

Platform-specific encoder implementations include:

  • EncoderWindowNV: NVENC for NVIDIA GPUs (all APIs)
  • EncoderWindowAMF: AMF for AMD GPUs (Vulkan, Direct3D12, Direct3D11)
  • EncoderWindowMTL: CoreMedia on Apple platforms
info

The EncoderWindow supports headless operation, making it suitable for offscreen rendering scenarios.

info

This plugin is used by the Executor tool for real-time wireless streaming to Oculus headsets.

#include <platform/encoder/include/TellusimEncoderStream.h>
#include <platform/encoder/include/TellusimEncoderWindow.h>
#include <platform/encoder/include/TellusimEncoderWindowAMF.h>
#include <platform/encoder/include/TellusimEncoderWindowMTL.h>
#include <platform/encoder/include/TellusimEncoderWindowNV.h>

Example

// Create window
ENCODER_WINDOW window(app.getPlatform(), app.getDevice());
if(!window) return false;

// Configure encoder
window.setKeyrate(4);
window.setFramerate(30);
window.setSize(app.getWidth(), app.getHeight());

// Encoder callback
window.setEncoderCallback([&](const uint8_t *data, size_t size, uint64_t frame) {
if(stream.writeH264(data, size)) {
uint32_t index = stream.getNumFragments() - 1;
if(index == 0) stream.getMP4Header(stream_mp4);
else stream.getMP4Fragment(stream_mp4, index);
stream.getH264Fragment(stream_h264);
}
});