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:
1 parent
ac47545aa3
commit
6274eedd12
7 files changed
+66
-9
No files matched your search
@@ -287,8 +287,13 @@ local function openAudio(demuxer: any, track: any): (any, Err.Err?)
|
||||
local dec, oerr = F.open(buf, { format = fmt, category = "audio" })
|
||||
-- Matroska CodecDelay: ffmpeg drops it for MPEG audio / AAC; Opus has its own pre-skip and Vorbis's delay is
|
||||
-- already the decoder's own (its first packet returns nothing)
|
||||
if dec and fmt ~= "opus" and fmt ~= "vorbis" and type(track.codecDelay) == "number" and track.codecDelay > 0 then
|
||||
dec = AudioWrap.trim(dec, math.floor(track.codecDelay * dec.sampleRate + 0.5))
|
||||
-- MP4 edit lists add the play length (the encoder's end padding is cut, as ffmpeg does)
|
||||
if dec and fmt ~= "opus" and fmt ~= "vorbis" then
|
||||
local skip = if type(track.codecDelay) == "number" and track.codecDelay > 0 then math.floor(track.codecDelay * dec.sampleRate + 0.5) else 0
|
||||
local length = if type(track.playDuration) == "number" and track.playDuration > 0 then math.floor(track.playDuration * dec.sampleRate + 0.5) else nil
|
||||
if skip > 0 or length then
|
||||
dec = AudioWrap.trim(dec, skip, length)
|
||||
end
|
||||
end
|
||||
return dec, oerr
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user