Skip to content

Commit

Permalink
libhb: drop short final BD chapters
Browse files Browse the repository at this point in the history
Pretty much every BD title has a final chapter that is only approx 1
second long. These get dropped during muxing, but can result in an
output file that has only a single chapter marker.

To be more consistant with how we handle other sources that consist of
only a single chapter, drop these short final chapters earlier so that
our logic to disable chapter markers for single chapter sources works as
expected for BD.

Fixes HandBrake#3414
  • Loading branch information
jstebbins committed Apr 20, 2024
1 parent 039758a commit 3778aeb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libhb/bd.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,11 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration )
char chapter_title[80];

// Sanity check start time of this chapter.
// If it is beyond the end of the title, drop it.
if (ti->chapters[ii].start > ti->duration)
// If the chapter starts within 1.5 seconds of the end of
// the title, drop it.
if (ti->duration - ti->chapters[ii].start < 90000 * 1.5)
{
hb_log("bd: chapter %d invalid start %"PRIu64", dropping", ii+1,
hb_log("bd: chapter %d too short %"PRIu64", dropping", ii+1,
ti->chapters[ii].start);
continue;
}
Expand Down Expand Up @@ -712,7 +713,7 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration )

hb_list_add( title->list_chapter, chapter );
}
hb_log( "bd: title %d has %d chapters", tt, ti->chapter_count );
hb_log( "bd: title %d has %d chapters", tt, hb_list_count(title->list_chapter));

/* This title is ok so far */
goto cleanup;
Expand Down

0 comments on commit 3778aeb

Please sign in to comment.