-- video/mpegps tests: program streams from ffmpeg (MPEG-1 system stream, B-frames, MPEG-2 PS / VOB packs, a raw .m1v -- elementary stream): tracks, picture packets (count and timestamps against ffmpeg's frames), frames against ffmpeg -- (PSNR) once an MPEG-1 decoder is registered, audio through the api hook (SNR), seeking, fuzz. Fixtures: -- tools/fixtures/mpegts.py. local T = require("@tests/T") local C = require("@tests/video/_common") local Ps = require("@formats/video/mpegps") local Bytes = require("@formats/core/Bytes") local Fx = require("@tests/gen/mpegps_cases") local t = T.suite("mpegps") t:eq(Ps.name, "mpegps", "name") for _, c in Fx do local label = c.name t:check(Ps.sniff(Bytes.reader(buffer.fromstring(c.data))) > 0, label .. ": sniff") local v, err = C.open(c.data) t:check(v ~= nil, label .. ": open " .. tostring(err)) if v then local dmx = v.demuxer local vt = dmx:track("video") t:check(vt ~= nil and vt.codec == "mpeg1", label .. ": an MPEG-1 video track") t:eq(dmx:count(vt.id), #c.frames, label .. ": one packet per picture") -- presentation times: one per frame slot local seen, ok = {}, true for k = 1, dmx:count(vt.id) do local pts = dmx:info(vt.id, k) local slot = math.floor((pts - dmx:info(vt.id, 1)) / 3600 + 0.5) if seen[slot] then ok = false end seen[slot] = true end t:check(ok, label .. ": distinct presentation times") C.frames(t, v, c, label, 36) if dmx:track("audio") then C.audio(t, v, c, label, false, 30) end C.seek(t, v, c, label, 0.5) end end local samples = {} for _, c in Fx do table.insert(samples, string.sub(c.data, 1, 30000)) end t:fuzz("open", C.fuzzOpen(Ps), samples, { mutations = 6, garbage = 100 }) t:done()