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

+5
View File
@@ -154,6 +154,9 @@ function Mp4.demux(r: Bytes.Reader, opts: OpenOptions?): (any, Err.Err?)
if it.skip and it.skip > 0 then
t.codecDelay = it.skip / it.timescale -- AAC priming: dropped like ffmpeg
end
if it.playDuration and it.playDuration > 0 and it.timescale > 0 then
t.playDuration = it.playDuration / it.timescale -- the edit's length: the end padding is not played
end
end
table.insert(tracks, t)
table.insert(src, it)
@@ -272,6 +275,8 @@ function Mp4.encode(value: any, opts: EncodeOptions?): (buffer?, Err.Err?)
for _, d in durations do
playDuration += d
end
elseif s.kind == "audio" and s.track and s.copied and type(s.track.playDuration) == "number" then
playDuration = math.floor(s.track.playDuration * scale + 0.5) -- keep the source's end trim
end
local t: any = {
kind = s.kind,