From fa2cfdb8ab616c5dd4d635915e541b07d4cb2113 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Thu, 1 Aug 2019 15:43:58 +0200 Subject: [PATCH] libeplayer3-arm: fix chapter Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/74c14dba99d9d427f192ee439a7f4e6a7dbf5203 Author: Jacek Jendrzej Date: 2019-08-01 (Thu, 01 Aug 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/container/container_ffmpeg.c | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libeplayer3/container/container_ffmpeg.c b/libeplayer3/container/container_ffmpeg.c index ae58f6f..99173b1 100644 --- a/libeplayer3/container/container_ffmpeg.c +++ b/libeplayer3/container/container_ffmpeg.c @@ -2053,6 +2053,35 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 } } } + uint32_t i = 0; + for (i = 0; i < avContext->nb_chapters; i++) + { + Track_t track; + AVChapter *ch = avContext->chapters[i]; + AVDictionaryEntry *title = av_dict_get(ch->metadata, "title", NULL, 0); + int chstart = ch->start * av_q2d(ch->time_base); + int chend = ch->end * av_q2d(ch->time_base); + char str[256]; + if (title) + snprintf(str, sizeof(str), "%s (%d - %d)", title->value, chstart, chend); + else + snprintf(str, sizeof(str), "%d (%d - %d)", i+1, chstart, chend); + chstart = (double) 1000 * ch->start * av_q2d(ch->time_base); + track.Name = str; + track.Encoding = "chapter"; + track.Id = avContext->nb_streams + i; + track.chapter_start = chstart; + track.chapter_end = chend; + if (context->manager->chapter) + { + ffmpeg_printf(1, "chapter[%d]: MANAGER_ADD track chapter\n", i); + if (context->manager->chapter->Command(context, MANAGER_ADD, &track) < 0) + { + /* konfetti: fixme: is this a reason to return with error? */ + ffmpeg_err("failed to add track %d\n", n); + } + } + } uint32_t n = 0; for (n = 0; n < avContext->nb_streams; n++)