ws-video: bench block (whole pipeline fps for MJPEG AVI / MPEG-1 TS / VP8 WebM / Y4M at 320x240 and 640x480, y4m -> MJPEG AVI), docs/video.md (API, layers, how a codec plugs into the registry), NOTICE row for mpegts-luau

This commit is contained in:
4DBug committed 2026-10-31 10:05:09 -05:00
1 parent 26f4e0cb60
commit 0c9094d28a
4 files changed
+139

No files matched your search

+49
View File
@@ -825,3 +825,52 @@ do
end
end
end
-- ------------------------------------------------------------------------------------------- ws-video: containers
do
local F = require("@formats")
local VB = require("@tests/gen/videobench")
local function clock(n: number, f: () -> number): (number, number)
local frames = f()
local dt = math.huge
for _ = 1, n do
local t0 = os.clock()
frames = f()
dt = math.min(dt, os.clock() - t0)
end
return dt, frames
end
for _, c in VB do
local data = buffer.fromstring(c.data)
local dtOpen = clock(3, function(): number
F.video.open(data, { audio = false })
return 1
end)
for _, rgba in { false, true } do
local ok, dt, frames = pcall(clock, 2, function(): number
local v = assert(F.video.open(data, { audio = false, rgba = rgba }))
local n = 0
while true do
local f, err = v:nextFrame()
if not f then
assert(err == nil, tostring(err))
break
end
n += 1
end
return n
end)
if ok then
print(string.format("%-8s %-30s %8.2f ms %7.1f fps (open %.1f ms)", runtime, string.format("video %s %s %s", c.size, c.name, if rgba then "rgba" else "yuv"), dt * 1000 / frames, frames / dt, dtOpen * 1000))
else
print(string.format("%-8s %-30s %s", runtime, "video " .. c.size .. " " .. c.name, tostring(dt)))
end
end
if c.name == "raw.y4m" then
local dt, frames = clock(2, function(): number
assert(F.convert(data, "avi", { quality = 85 }))
return 8
end)
print(string.format("%-8s %-30s %8.2f ms %7.1f fps", runtime, "video " .. c.size .. " y4m -> mjpeg avi", dt * 1000 / frames, frames / dt))
end
end
end