ws-video2-flv: FLV writer test from ADTS AAC (MPEG-TS), bench lines (H.263 / Sorenson CIF fps), docs/guide/video.md FLV and H.263 section (inputs: tools/fixtures/docs_flv.py)

This commit is contained in:
4DBug committed 2026-10-31 15:13:14 -05:00
1 parent efc0812746
commit f23d0aa3e8
5 files changed
+105 -3

No files matched your search

+34
View File
@@ -1078,3 +1078,37 @@ do
jitTune(false)
end
end
-- ------------------------------------------------------------------------------------------- ws-video2-flv: fps
do
-- H.263 / Sorenson Spark (codecs/video/H263, tools/fixtures/h263.py): CIF mandelbrot zooms (1 Mbit/s, an I picture
-- every 12), one picture per decode, planes only (frameImage copies excluded) and with the yuv420p Image copies
local H263 = require("@formats/codecs/video/H263")
local Base64 = require("@formats/core/Base64")
local HB = require("@tests/gen/h263_bench")
local function run(tag: string)
for _, c in HB do
local file = Base64.decode(c.file) :: buffer
for _, images in { false, true } do
local n = #c.units
local dt = bench(string.format("%s %dx%d%s%s", c.name, c.width, c.height, if images then " +img" else "", tag), 3, c.width * c.height * 3 // 2 * n, function()
local dec = H263.new({ flv = c.flv })
for _, u in c.units do
if images then
dec:image(file, u[1], u[2])
else
dec:decode(file, u[1], u[2])
end
end
end)
print(string.format("%-8s %-30s %8.1f fps", runtime, " (" .. n .. " frames)", n / dt))
end
end
end
jitTune(false)
run("")
if runtime == "luajit" then
jitTune(true)
run(" (jit tuned)")
jitTune(false)
end
end
+2 -1
View File
@@ -30,10 +30,11 @@ local JOBS = {
{ "mp4_h264_aac.flv", "mp4", Src.mp4 },
{ "mkv_h264_mp3.flv", "mkv", Src.mkv },
{ "ts_h264_aac.flv", "ts", Src.ts },
{ "ts_aac.flv", "ts", Src.ts, { video = false } }, -- ADTS AAC re-framed
}
for _, j in JOBS do
local name, source, data = j[1], j[2], j[3]
local out, err = F.convert(buffer.fromstring(data), "flv")
local out, err = F.convert(buffer.fromstring(data), "flv", j[4])
if out then
print(name .. " " .. source .. " " .. hex(out))
else
+29
View File
@@ -0,0 +1,29 @@
# Docs inputs for the FLV / H.263 sections of docs/guide/video.md (tools/fixtures.py; tools/docs_check.py reads them):
# tiny ffmpeg clips (testsrc 64x48, 10 frames at 10 fps, with a sine track): FLV with Sorenson Spark + MP3, a 3GP with
# H.263 (QCIF, the H.263 size closest to the clip) and AAC.
# tests/gen/docs_flv.luau { files = { [name] = bytes }, vars = { flvBytes = "clip.flv", h263Bytes = "clip.3gp" } }
import importlib.util, os, shutil, subprocess, tempfile
INPUTS = ["tools/docs_check.py"]
def generate(ctx):
spec = importlib.util.spec_from_file_location("docs_flv_check", os.path.join(ctx.root, "tools", "docs_check.py"))
dc = importlib.util.module_from_spec(spec)
spec.loader.exec_module(dc)
files = {}
with tempfile.TemporaryDirectory() as d:
for name, size, codec in (
("clip.flv", "64x48", ["-c:v", "flv", "-g", "5", "-c:a", "libmp3lame", "-b:a", "64k"]),
("clip.3gp", "176x144", ["-c:v", "h263", "-g", "5", "-c:a", "aac", "-b:a", "32k", "-ar", "22050"]),
):
src = ["-f", "lavfi", "-i", "testsrc=size=%s:rate=10:duration=1" % size,
"-f", "lavfi", "-i", "sine=frequency=440:sample_rate=44100:duration=1"]
out = os.path.join(d, name)
argv = ["-v", "error", "-y"] + src + codec + ["-shortest", out]
if shutil.which("ffmpeg"):
subprocess.run(["ffmpeg"] + argv, check=True, capture_output=True)
else:
ctx.nix("ffmpeg", ["ffmpeg"] + argv)
files[name] = open(out, "rb").read()
dc.emit_inputs(ctx, files, {"flvBytes": "clip.flv", "h263Bytes": "clip.3gp"})