ws-apifix: MP4 AAC length matches ffmpeg: the edit list's length (Track.playDuration) cuts the end padding as well as the priming (codecDelay); a 1 s clip decodes to 44100 frames, not 45056. AudioWrap.trim(dec, skip, length?); the MP4 writer keeps the edit length of copied audio. Video tests compare the whole decoded audio length with ffmpeg (not yet for Matroska)

This commit is contained in:
4DBug committed 2026-10-31 14:13:08 -05:00
1 parent ac47545aa3
commit 6274eedd12
7 files changed
+66 -9

No files matched your search

+15
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