diff options
author | Rodeo <[email protected]> | 2012-05-03 16:04:28 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-05-03 16:04:28 +0000 |
commit | 4aeadc9bc63d200d6c0b709eba7e25c4f3afe24c (patch) | |
tree | 4d73da1a557826fd4b553172180f6cd455b5ecbb /libhb/stream.c | |
parent | 9b3507211cff2ddf6bec9072d7767e461bdc0fa7 (diff) |
libhb: if no source chapter name information is available, set default chapters names explicitly (rather than leaving it to the interfaces).
Standardize calculation of chapter->hours, chapter->minutes and chapter->seconds across all sources.
Get rid of an unused variable in libhb/dvd.c
Ignore chapter names set by MakeMKV. "Chapter 1" is just as good as, if not better than "Chapter 01" or even "Chapter 00".
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4636 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rw-r--r-- | libhb/stream.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index 7961eebfb..48b1e9742 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -5501,15 +5501,29 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) chapter->index = i+1; chapter->duration = ( m->end / ( (double) m->time_base.num * m->time_base.den ) ) * 90000 - duration_sum; duration_sum += chapter->duration; - chapter->hours = chapter->duration / 90000 / 3600; - chapter->minutes = ( ( chapter->duration / 90000 ) % 3600 ) / 60; - chapter->seconds = ( chapter->duration / 90000 ) % 60; + + int seconds = ( chapter->duration + 45000 ) / 90000; + chapter->hours = ( seconds / 3600 ); + chapter->minutes = ( seconds % 3600 ) / 60; + chapter->seconds = ( seconds % 60 ); + tag = av_dict_get( m->metadata, "title", NULL, 0 ); - strcpy( chapter->title, tag ? tag->value : "" ); + /* Ignore generic chapter names set by MakeMKV ("Chapter 00" etc.). + * Our default chapter names are better. */ + if( tag && tag->value && + ( strncmp( "Chapter ", tag->value, 8 ) || strlen( tag->value ) > 11 ) ) + { + strcpy( chapter->title, tag->value ); + } + else + { + sprintf( chapter->title, "Chapter %d", chapter->index ); + } + hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRIu64", (%02i:%02i:%02i)", - chapter->index, chapter->title, - chapter->duration, chapter->hours, - chapter->minutes, chapter->seconds ); + chapter->index, chapter->title, chapter->duration, + chapter->hours, chapter->minutes, chapter->seconds ); + hb_list_add( title->list_chapter, chapter ); } } |