merge master (ws/apifix)

This commit is contained in:
4DBug committed 2026-10-31 14:26:11 -05:00
commit 48b4b4cc4e
39 files changed
+1158 -73

No files matched your search

+1 -1
View File
@@ -193,7 +193,7 @@ for _, c in Cases do
t:check(a.meta.source.format == "mp3" and a.meta.source.layer == dec.layer, name .. ": meta.source")
t:eq(Mp3.sniff(Bytes.reader(buf)) > 0.5, true, name .. ": sniff")
t:note("%-20s L%d MPEG-%s %5d Hz %d ch %6d frames %3d kbps SNR minimp3 %s, ffmpeg %.1f dB", name, dec.layer, tostring(dec.version), dec.sampleRate, ch, dec.frames, dec.bitrate, if ref then string.format("%.1f", worst) else "-", worstFF)
t:note("%-20s L%d MPEG-%s %5d Hz %d ch %6d frames %3d kbps SNR minimp3 %s, ffmpeg %.1f dB", name, dec.layer, tostring(dec.version), dec.sampleRate, ch, dec.frames, dec.bitrate // 1000, if ref then string.format("%.1f", worst) else "-", worstFF)
end
-- ------------------------------------------------------------------------------------------------ robustness
+8
View File
@@ -102,6 +102,13 @@ do
local f1 = Mp3.encode(a, { bitrate = 128 }) :: buffer
local f2 = Mp3.encode(Pcm.audioDecoder(a), { bitrate = 128 }) :: buffer
t:check(buffer.tostring(f1) == buffer.tostring(f2), "Decoder source = Audio source")
-- bitrate in bit/s (the documented unit), and the old kbit/s values below 1000: the same file
local f4 = Mp3.encode(a, { bitrate = 128000 }) :: buffer
t:check(f4 ~= nil and buffer.tostring(f1) == buffer.tostring(f4), "bitrate 128000 bit/s = 128 kbit/s")
local d4 = Mp3.open(Bytes.reader(f4)) :: any
t:check(math.abs(d4.bitrate - 128000) < 1000, "the decoder reports bit/s: " .. tostring(d4.bitrate))
local _, e5 = Mp3.encode(a, { bitrate = 127000 })
t:check(e5 and e5.code == Err.ARG and string.find(e5.message, "127000 bit/s", 1, true) ~= nil, "127000 bit/s refused: " .. tostring(e5))
a.tags = { title = "Ünïcode title", artist = "An Artist", album = "Album", track = "4", comment = "made here" }
local f3 = Mp3.encode(a, { layer = 2 }) :: buffer
t:eq(buffer.readstring(f3, 0, 3), "ID3", "an ID3v2 tag in front")
@@ -169,6 +176,7 @@ do
t:eq(code({}, nil), Err.ARG, "junk")
t:eq(code(a, { layer = 1 }), Err.ARG, "layer I")
t:eq(code(a, { bitrate = 100 }), Err.ARG, "100 kbps")
t:eq(code(a, { bitrate = 100000 }), Err.ARG, "100000 bit/s")
t:eq(code(a, { mode = "dual" }), Err.ARG, "dual mode")
t:eq(code(a, { sampleRate = 44000 }), Err.ARG, "opts.sampleRate 44 kHz")
t:eq(code(a, { layer = 2, sampleRate = 8000 }), Err.ARG, "layer II at 8 kHz")
+3
View File
@@ -85,6 +85,9 @@ do
t:check(again, "encode from a decoder: " .. tostring(err))
local back = Opus.decode(Bytes.reader(again :: buffer)) :: any
t:eq(back.frames, math.floor(c.seconds * 48000 + 0.5), "re-encoded length")
-- values below 1000 are kbit/s: the same file as the bit/s value
local kb = Opus.encode(Opus.open(Bytes.reader(files[1] :: buffer)) :: any, { bitrate = 64 })
t:check(kb ~= nil and buffer.tostring(kb :: buffer) == buffer.tostring(again :: buffer), "bitrate 64 = 64000 bit/s")
end
-- errors
+26
View File
@@ -137,6 +137,32 @@ do
-- an outline font saved as fnt is baked on the way
local fnt = F.convert(Fx.ttf, "fnt", { px = 16 })
t:check(fnt and string.sub(buffer.tostring(fnt), 1, 9) == "info face", "F.convert ttf -> fnt (text)")
-- the baked pages: returned as the third value without a destination ({ [page file] = PNG bytes }) ...
local desc, derr, pages = F.save(ttf, nil, { format = "bmfont", px = 16, chars = "Hi" })
t:check(desc and derr == nil and type(pages) == "table", "F.save(ttf, bmfont) returns the pages")
local png = pages and pages["font_0.png"]
t:check(png and F.detect(png) == "png", "page 0 as PNG under the descriptor's name")
local again = F.font.load(desc, { loadPage = function(file: string): any
return pages and pages[file]
end })
local hg = again and again:rasterize(again:glyphIndex(string.byte("H")))
local ref = Bmfont.bake(ttf, { px = 16, chars = "Hi" })
local rg = ref:rasterize(ref:glyphIndex(string.byte("H")))
t:check(hg and rg and Crc32.of(hg.pixels) == Crc32.of(rg.pixels), "the saved page gives the baked glyph back")
-- ... or into the caller's opts.files (then not returned), named after opts.name / opts.file
local mine = {}
local d2, _, p2 = F.save(ttf, nil, { format = "bmfont", px = 16, chars = "Hi", files = mine, name = "ui.fnt" })
t:check(d2 and p2 == nil and mine["ui_0.png"] ~= nil, "opts.files filled, pages named after opts.name")
t:check(string.find(buffer.tostring(d2), 'file="ui_0.png"', 1, true) ~= nil, "descriptor names the page")
local _, _, p3 = F.save(ttf, nil, { format = "bmfont", px = 16, chars = "Hi", file = "x" })
t:check(p3 and p3["x_0.png"] ~= nil, "opts.file sets the prefix")
-- a loaded BMFont with its pages: re-saved with them; without pages: the descriptor alone
local _, _, p4 = F.save(again, nil, { format = "bmfont" })
t:check(p4 == nil or p4["font_0.png"] ~= nil, "lazy pages not loaded: descriptor only")
local _, _, p5 = F.save(ref, nil, { format = "bmfont" })
t:check(p5 and p5["font_0.png"] ~= nil, "a baked font re-saved with its pages")
-- direct calls without the hooks: no pages, no error
t:check(Bmfont.encode(ttf, { px = 16, chars = "Hi", files = {} }) ~= nil, "encode without encodeImage")
end
-- 6. errors and validation
+17
View File
@@ -169,6 +169,23 @@ do
t:check(nope == nil and nerr.code == Err.ARG, "encode refuses nil")
end
-- track.name is written as a 0x03 meta event at tick 0 when the track has none; an existing one wins
do
local m = Types.Midi.new(96)
local notes = { { tick = 0, type = "noteOn", channel = 0, data = { 60, 100 } }, { tick = 96, type = "noteOff", channel = 0, data = { 60, 0 } } }
m.tracks[1] = { name = "Lead", events = notes }
m.tracks[2] = { name = "Ignored", events = { { tick = 0, type = "meta", meta = 0x03, data = { string.byte("Bass", 1, -1) } } } }
m.tracks[3] = { name = "", events = {} }
local back = decode(Midi.encode(m) :: buffer)
t:eq(back.tracks[1].name, "Lead", "track.name written")
local first = back.tracks[1].events[1]
t:check(first.type == "meta" and first.meta == 0x03 and first.tick == 0, "as a 0x03 event at tick 0")
t:eq(#back.tracks[1].events, 4, "name + 2 notes + end of track")
t:eq(back.tracks[2].name, "Bass", "the track's own 0x03 event wins")
t:eq(back.tracks[3].name, nil, "empty name: nothing written")
t:eq(#m.tracks[1].events, 2, "the caller's events are not changed")
end
-- crafted bad files
for _, c in Bad do
local ok, m, err = pcall(decode, c.data)
+13
View File
@@ -110,6 +110,19 @@ do
g.opacity = 0.5
local r3 = get(LayerOps.flatten(doc({ bottom, g })))
t:check(math.abs(r3 - 150) <= 1, "pass-through opacity mixes before / after: " .. r3)
-- a pass-through group's mask limits its effect: black hides it, grey mixes, outside the mask = its default
g.opacity = 1
local m = Types.Image.new(1, 1, "gray8")
g.mask = { image = m, x = 0, y = 0, default = 255 }
t:eq((get(LayerOps.flatten(doc({ bottom, g })))), 200, "pass-through: black mask hides the group")
buffer.writeu8(m.pixels, 0, 128)
local r4 = get(LayerOps.flatten(doc({ bottom, g })))
t:check(math.abs(r4 - 150) <= 1, "pass-through: grey mask mixes: " .. r4)
g.mask = { image = m, x = 3, y = 3, default = 0 }
t:eq((get(LayerOps.flatten(doc({ bottom, g })))), 200, "pass-through: outside the mask, default black")
g.mask.disabled = true
t:check(math.abs(get(LayerOps.flatten(doc({ bottom, g }))) - 100) <= 1, "pass-through: disabled mask ignored")
g.mask = nil
end
-- frames, leaves, flattenFrames
do
+157
View File
@@ -0,0 +1,157 @@
-- ops/MusicOps tests (F.music.new / addPattern / setCell / getCell / addSample / addInstrument / note) and the
-- music-as-audio bridges of the api: F.save / F.convert of a Module or a Midi to an audio format (rendered, render
-- options through opts), F.audio.open / F.audio.load of music bytes. Everything is built here (no fixtures).
local T = require("@tests/T")
local F = require("@formats")
local Err = require("@formats/core/Err")
local t = T.suite("musicops")
-- a 1 s 440 Hz sine at 8363 Hz (MOD's C-4 rate)
local function sine(rate: number, frames: number): any
local a = F.Types.Audio.new(rate, 1, frames)
for i = 0, frames - 1 do
buffer.writef32(a.samples, i * 4, math.sin(i / rate * 2 * math.pi * 440) * 0.5)
end
return a
end
-- note names
do
t:eq(F.music.note("C-0"), 1, "C-0")
t:eq(F.music.note("C-4"), 49, "C-4")
t:eq(F.music.note("c#4"), 50, "C#4")
t:eq(F.music.note("Db4"), 50, "Db4")
t:eq(F.music.note("B-9"), 120, "B-9")
t:eq(F.music.note("off"), 255, "key off")
t:eq(F.music.note("cut"), 254, "note cut")
t:eq(F.music.note(61), 61, "a number")
for _, badNote in { "H-4", "C-", 121, "Cb0", {}, -1 } do
local n, e = F.music.note(badNote)
t:check(n == nil and e and e.code == Err.ARG, "bad note " .. tostring(badNote))
end
end
-- a MOD built from scratch: saved, reloaded, rendered
local a = sine(8363, 8363)
local song = assert(F.music.new({ format = "mod", channels = 4, title = "demo", speed = 3 }))
do
t:eq(song.kind, "music", "kind")
t:eq(song.meta.source.format, "mod", "source format")
local s = assert(F.music.addSample(song, { name = "sine", audio = a, loop = "forward", volume = 48 }))
t:eq(s, 1, "sample number")
local p = assert(F.music.addPattern(song))
t:eq(p, 0, "pattern number")
t:eq(#song.order, 1, "appended to the order")
t:check(F.music.setCell(song, p, 0, 1, { note = "C-4", instrument = s }), "setCell")
t:check(F.music.setCell(song, p, 32, 2, { note = "E-4", instrument = s, effect = 0xC, param = 32 }), "setCell 2")
local c = assert(F.music.getCell(song, p, 32, 2))
t:check(c.note == 53 and c.instrument == 1 and c.effect == 0xC and c.param == 32 and c.volume == 0, "getCell")
-- bad arguments
local _, e1 = F.music.setCell(song, p, 64, 1, {})
t:check(e1 and e1.code == Err.ARG, "row out of range")
local _, e2 = F.music.setCell(song, p, 0, 5, {})
t:check(e2 and e2.code == Err.ARG, "channel out of range")
local _, e3 = F.music.setCell(song, 7, 0, 1, {})
t:check(e3 and e3.code == Err.ARG, "no such pattern")
local _, e4 = F.music.setCell(song, p, 0, 1, { param = 300 })
t:check(e4 and e4.code == Err.ARG, "param out of range")
local _, e5 = F.music.addInstrument(song, { sample = 1 })
t:check(e5 and e5.code == Err.ARG, "MOD has no instruments")
local _, e6 = F.music.new({ format = "mid" })
t:check(e6 and e6.code == Err.ARG, "unknown tracker format")
local _, e7 = F.music.addSample(song, { audio = F.Types.Audio.new(8000, 3, 4) })
t:check(e7 and e7.code == Err.ARG, "3-channel sample")
local _, e8 = F.music.addPattern({} :: any)
t:check(e8 and e8.code == Err.ARG, "not a module")
local mod = assert(F.save(song)) -- the source format
t:eq(F.detect(mod), "mod", "saved as MOD")
local back = assert(F.music.load(mod))
t:eq(back.title, "demo", "title round trip")
t:check(back.samples[1].loopType == 1 and back.samples[1].volume == 48, "sample loop / volume round trip")
local c2 = assert(F.music.getCell(back, 0, 32, 2))
t:check(c2.note == 53 and c2.instrument == 1 and c2.effect == 0xC and c2.param == 32, "cells round trip")
local dec = assert(song:render({ sampleRate = 22050 }))
local au = assert(F.ops.audio.toAudio(dec))
t:check(au.frames > 22050 and F.ops.audio.peak(au) > 0.05, "renders sound")
end
-- an XM with an instrument and a volume envelope
do
local xm = assert(F.music.new({ format = "xm", channels = 2 }))
local s = assert(F.music.addSample(xm, { audio = a, rate = 16726 })) -- an octave up: relativeNote 12
t:eq(xm.samples[s].relativeNote, 12, "rate -> relativeNote")
t:eq(xm.samples[s].finetune, 0, "rate -> finetune")
local i = assert(F.music.addInstrument(xm, { name = "lead", sample = s, fadeout = 512, envelope = { points = { { 0, 64 }, { 10, 32 }, { 40, 0 } }, sustain = 2 } }))
local p = assert(F.music.addPattern(xm, 32))
assert(F.music.setCell(xm, p, 0, 1, { note = "C-4", instrument = i }))
assert(F.music.setCell(xm, p, 16, 1, { note = "off" }))
local back = assert(F.music.load(assert(F.save(xm))))
t:check(back.format == "xm" and #back.instruments == 1 and back.instruments[1].name == "lead", "XM instrument round trip")
t:check(back.instruments[1].volEnv and back.instruments[1].volEnv.enabled and #back.instruments[1].volEnv.ticks == 3, "XM envelope round trip")
local _, ebad = F.music.addInstrument(xm, { sample = 9 })
t:check(ebad and ebad.code == Err.ARG, "instrument on a missing sample")
local _, eenv = F.music.addInstrument(xm, { envelope = { points = { { 5, 10 }, { 5, 20 } } } })
t:check(eenv and eenv.code == Err.ARG, "envelope ticks must increase")
end
-- music saved and converted as audio: rendered, with the render options from opts
do
local wav = assert(F.save(song, nil, { format = "wav", sampleRate = 22050 }))
local au = assert(F.audio.load(wav))
t:check(au.sampleRate == 22050 and au.channels == 2 and au.frames > 0, "F.save(module, wav) renders")
local mod = assert(F.save(song))
local w2 = assert(F.convert(mod, "wav", { sampleRate = 11025 }))
t:eq(F.detect(w2), "wav", "F.convert(mod, wav)")
t:eq((assert(F.audio.load(w2))).sampleRate, 11025, "convert passes sampleRate to the render")
t:check(F.audio.save(song, nil, { format = "flac" }) ~= nil, "F.audio.save(module)")
local m = F.Types.Midi.new(480)
table.insert(m.tracks, { events = {
{ tick = 0, type = "noteOn", channel = 0, data = { 60, 100 } },
{ tick = 480, type = "noteOff", channel = 0, data = { 60, 0 } },
} })
local mw = assert(F.save(m, nil, { format = "wav", tail = 0.5 })) -- a hand-built Midi (no render method)
local ma = assert(F.audio.load(mw))
t:eq(ma.frames, math.floor(1.0 * 44100 + 0.5), "Midi rendered: 0.5 s of notes + 0.5 s tail")
local mid = assert(F.save(m, nil, { format = "midi" }))
t:eq(F.detect(assert(F.convert(mid, "wav"))), "wav", "F.convert(midi, wav)")
-- F.audio.open / load of music bytes: the rendered Decoder
local d1 = assert(F.audio.open(mid, { tail = 0 }))
t:check(d1.channels == 2 and d1.sampleRate == 44100 and d1.frames == 22050, "F.audio.open(midi)")
local d2 = assert(F.audio.open(mod))
t:check(d2.channels == 2 and d2.frames > 0, "F.audio.open(mod)")
local a2 = assert(F.audio.load(mod, { sampleRate = 8000 }))
t:check(a2.kind == "audio" and a2.sampleRate == 8000, "F.audio.load(mod)")
local d3 = assert(F.audio.open(mod, { format = "mod" }))
t:check(d3.frames > 0, "F.audio.open with format = mod")
-- still an error for data no format reads
local _, e = F.audio.open(buffer.fromstring("not audio at all"))
t:check(e and e.code == Err.UNKNOWN_FORMAT, "unknown data")
-- and a soundfont is not audio
local _, e2 = F.audio.save(m, nil, { format = "png" })
t:check(e2 ~= nil, "music to a non-audio format fails")
end
-- no throws on random cell / sample arguments
do
local rng = T.rng(7)
local ok = true
for _ = 1, 300 do
local vals = { rng(300) - 20, "C-4", nil, {}, -1, 0.5, 1e9 }
local pick = function(): any
return vals[rng(#vals) + 1]
end
local pok = pcall(function()
F.music.setCell(song, pick(), pick(), pick(), { note = pick(), instrument = pick(), param = pick() })
F.music.getCell(song, pick(), pick(), pick())
F.music.addSample(song, { data = buffer.create(rng(16)), length = pick(), loop = "forward", loopStart = pick(), loopEnd = pick() })
end)
ok = ok and pok
end
t:check(ok, "random arguments never throw")
end
t:done()
+21
View File
@@ -152,6 +152,21 @@ function C.audio(t: any, v: any, c: any, label: string, exact: boolean?, minSnr:
end
local n = got * a.channels
t:check(n == want or n * 4 == c.pcmBytes, label .. ": " .. n .. " samples read of " .. want)
-- the whole stream: as long as ffmpeg's decode (priming and end padding trimmed the same way: MP4 edit lists).
-- Not yet for Matroska / WebM, where ffmpeg also cuts the end padding of the last packets (Vorbis, MP2: a few
-- hundred frames) and we do not.
if c.pcmBytes and v.format ~= "mkv" and v.format ~= "webm" then
local total = got
while true do
local _, k = a:read(4096)
if not k or k <= 0 then
break
end
total += k
end
t:eq(total * a.channels * 4, c.pcmBytes, label .. ": decoded length = ffmpeg's (" .. total .. " frames)")
a:seek(0)
end
n = math.min(n, want)
if exact then
local same = true
@@ -180,6 +195,12 @@ function C.seek(t: any, v: any, c: any, label: string, at: number)
v:seek(at)
local f = v:nextFrame()
t:check(f ~= nil and f.pts >= at - 1e-6 and f.pts < at + 0.2, label .. ": seek to " .. at .. " lands at " .. tostring(f and f.pts))
if f and v.frameRate > 0 then
-- frame.index restarts at the seek position (not counted on from before the seek)
t:eq(f.index, math.floor(f.pts * v.frameRate + 0.5) + 1, label .. ": frame index after seeking")
local g = v:nextFrame()
t:check(g == nil or g.index == f.index + 1, label .. ": index counts on after the seek")
end
if f and C.EXACT[v.codec] and c.frames then
local idx = math.floor(f.pts * v.frameRate + 0.5) + 1
t:eq(Crc32.of(f.image.pixels), c.frames[idx], label .. ": the frame after seeking equals ffmpeg's frame " .. idx)
+57
View File
@@ -113,4 +113,61 @@ do
t:check(out ~= nil and buffer.tostring(out) == gifAvi.data, "gif.avi: F.convert(gif, 'avi') again byte for byte")
end
end
-- frame.index after seek on a demuxed video (MJPEG AVI at 10 fps): the frame's own position, then counting on
local function gradient(n: number): { any }
local imgs = {}
for i = 1, n do
local im = assert(F.ops.image.new(16, 8))
F.ops.image.fill(im, i * 12, 0, 255 - i * 12)
imgs[i] = im
end
return imgs
end
local avi = assert(F.save(assert(F.video.fromFrames(gradient(20), 0.1)), nil, { format = "avi", quality = 90 }))
do
local v = assert(F.video.open(avi))
for i = 1, 3 do
t:eq((v:nextFrame() :: any).index, i, "index before seeking " .. i)
end
v:seek(1.0)
local f = v:nextFrame() :: any
t:check(f.index == 11 and math.abs(f.pts - 1.0) < 1e-6, "seek(1.0): frame 11")
t:eq((v:nextFrame() :: any).index, 12, "then 12")
v:seek(0.25)
t:eq((v:nextFrame() :: any).index, 4, "seek back to 0.25: frame 4 (0.3 s)")
v:reset()
t:eq((v:nextFrame() :: any).index, 1, "reset: frame 1")
end
-- a video saved as an animated image (GIF / APNG / WebP): every frame with its timing, or frames / fps / maxFrames
do
local gif = assert(F.convert(avi, "gif"))
t:eq(F.detect(gif), "gif", "convert(avi, gif)")
local g = assert(F.image.load(gif))
t:check(#g.frames == 20 and math.abs(g.frames[1].delay - 0.1) < 1e-9 and g.width == 16 and g.height == 8, "gif: 20 frames of 0.1 s")
local g2 = assert(F.image.load(assert(F.convert(avi, "gif", { fps = 5 }))))
t:check(#g2.frames == 10 and math.abs(g2.frames[1].delay - 0.2) < 1e-9, "fps = 5: 10 frames of 0.2 s")
local g3 = assert(F.image.load(assert(F.convert(avi, "gif", { fps = 20 }))))
local total = 0
for _, fr in g3.frames do
total += fr.delay
end
t:check(#g3.frames == 20 and math.abs(total - 2) < 0.02, "fps above the source: frames held, total 2 s")
t:eq(#(assert(F.image.load(assert(F.convert(avi, "gif", { frames = 4 })))) :: any).frames, 4, "frames = 4")
t:eq(#(assert(F.image.load(assert(F.convert(avi, "gif", { maxFrames = 7 })))) :: any).frames, 7, "maxFrames = 7")
t:eq(#(assert(F.image.load(assert(F.convert(avi, "gif", { maxPixels = 16 * 8 * 5 })))) :: any).frames, 5, "maxPixels caps the frames")
local apng = assert(F.save(assert(F.video.open(avi)), nil, { format = "apng" }))
local a = assert(F.image.load(apng))
t:check(F.detect(apng) == "png" and #a.frames == 20, "save(video, apng)")
local webp = assert(F.save(assert(F.video.open(avi)), nil, { format = "webp" }))
t:check(F.detect(webp) == "webp" and #(assert(F.image.load(webp)) :: any).frames == 20, "save(video, webp)")
-- the frames are the decoded pictures: the GIF's first frame is the MJPEG frame (lossy, palette)
local v = assert(F.video.open(avi))
local first = v:toRGBA(v:nextFrame())
local r1 = buffer.readu8(first.pixels, 0)
t:check(math.abs(buffer.readu8(g.pixels, 0) - r1) <= 8, "gif frame 1 matches the decoded frame")
local _, e = F.save(assert(F.video.open(avi)), nil, { format = "gif", fps = -1 })
t:check(e and e.code == F.Err.ARG, "bad fps")
end
t:done()
+10
View File
@@ -88,6 +88,16 @@ do
t:eq(len, 160, "lacing: EBML-laced frame size")
end
-- F.detect names WebM files (DocType webm) "webm", Matroska files "mkv"; both open through the mkv format
do
t:eq(F.detect(byName["vp8_opus.webm"].data), "webm", "detect: webm")
t:eq(F.detect(byName["mjpeg_pcm.mkv"].data), "mkv", "detect: mkv")
t:eq(Mkv.variant(Bytes.reader(buffer.fromstring(byName["vp8_opus.webm"].data))), "webm", "variant: webm")
t:eq(Mkv.variant(Bytes.reader(buffer.fromstring(byName["mjpeg_pcm.mkv"].data))), nil, "variant: matroska")
t:eq(Mkv.variant(Bytes.reader(buffer.fromstring("\26\69\223\163"))), nil, "variant: truncated")
t:eq(F.format("webm").name, "mkv", "format(webm) is mkv")
end
-- 4. our muxer: remux WebM (VP8 + Opus copied) and read it back packet for packet
do
local src = byName["vp8_opus.webm"]
+10
View File
@@ -62,6 +62,16 @@ for _, job in { { "mjpeg_aac.mp4", "mp4" }, { "mjpeg_pcm.mov", "mov" }, { "h264_
end
end
t:check(same, "write " .. job[1] .. ": same packets and times")
-- copied AAC keeps its edit list: priming and end padding cut as in the source (ffmpeg's length)
local at = a:track("audio")
if at and at.codec == "aac" then
local bt = b:track("audio")
t:check(bt and bt.playDuration and math.abs(bt.playDuration - at.playDuration) < 1e-3 and math.abs((bt.codecDelay or 0) - (at.codecDelay or 0)) < 1e-6, "write " .. job[1] .. ": edit list kept")
if v2.audio and src.pcmBytes then
local all = assert(F.ops.audio.toAudio(v2.audio))
t:eq(all.frames * all.channels * 4, src.pcmBytes, "write " .. job[1] .. ": AAC length = ffmpeg's decode of the source")
end
end
end
end
end