Always change the last chapter's length to coincide with the end of the audio file.

This commit is contained in:
Michael Bucari-Tovo 2025-05-09 13:36:07 -06:00
parent dfb63d3275
commit 20e792c589

View File

@ -184,16 +184,13 @@ namespace FileLiberator
fileDuration -= TimeSpan.FromMilliseconds(options.ContentMetadata.ChapterInfo.BrandOutroDurationMs); fileDuration -= TimeSpan.FromMilliseconds(options.ContentMetadata.ChapterInfo.BrandOutroDurationMs);
var durationDelta = fileDuration - options.ChapterInfo.EndOffset; var durationDelta = fileDuration - options.ChapterInfo.EndOffset;
if (durationDelta.TotalMilliseconds > 0) //Remove the last chapter and re-add it with the durationDelta that will
{ //make the chapter's end coincide with the end of the audio file.
//only fix chapters which are shorter than the file. Chapters which are longer
//than the file will be truncated to match the file length, which is correct.
var chapters = options.ChapterInfo.Chapters as List<AAXClean.Chapter>; var chapters = options.ChapterInfo.Chapters as List<AAXClean.Chapter>;
var lastChapter = chapters[^1]; var lastChapter = chapters[^1];
chapters.Remove(lastChapter); chapters.Remove(lastChapter);
options.ChapterInfo.Add(lastChapter.Title, lastChapter.Duration + durationDelta); options.ChapterInfo.Add(lastChapter.Title, lastChapter.Duration + durationDelta);
}
#endregion #endregion