Builtin Library
README.md
video Module
Public Luau surface over the __video Internal FFI namespace — video
playback via render-target-backed players.
Purpose
Wrap the raw __video.* FFI namespace (backed by zero_video) in a
typed Luau table that gets auto-injected as _G.video via the
prelude. Players are backed by standard render targets — the handle
returned by video.create is an "rt:video_N" string usable anywhere
a render target works (materials, UI, post-process inputs).
Usage
-- Stream a video onto a material
local rt = video.create("http://example.com/clip.mp4", {
loop = true, autoplay = true, rate = 1.0,
})
material.setTexture(myMat, "baseColor", rt)
-- Transport
video.pause(rt); video.seek(rt, 30.5); video.play(rt)
-- Inspect
local info = video.getInfo(rt)
print(info.width, info.height, info.currentTime, "/", info.duration)
-- Ask whether this host decodes the stream before waiting on a frame.
-- `codecSupported` is nil until the answer arrives, false where the host has
-- no decoder for `info.codec`, and then `info.state` is `"unsupported"`.
if info.codecSupported == false then
print(info.error)
end
-- Frames handed to the texture against frames the playback clock reached,
-- and how many samples decoded on the frame thread (a native stream decodes
-- on a thread of its own; a browser stream in the browser's decoder).
print(info.framesPresented, "/", info.framesExpected, info.frameThreadDecodes)
video.destroy(rt)
Exports
video.create(url, options?) -> rtHandlevideo.play(handle)/video.pause(handle)/video.stop(handle)video.seek(handle, time)video.setRate(handle, rate)/video.setLoop(handle, loop)video.getInfo(handle) -> VideoInfo?video.destroy(handle)