From: Carl Hetherington Date: Tue, 4 Oct 2016 10:54:45 +0000 (+0100) Subject: Fix subtitle_id to work with _TEXT and _ASS subtitles (fixes #969). X-Git-Tag: v2.9.31~7 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=4750382795aaf7964cfc4af9483d30dd4e565b4c Fix subtitle_id to work with _TEXT and _ASS subtitles (fixes #969). --- diff --git a/ChangeLog b/ChangeLog index 1ff419057..5e3694e66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-10-04 c.hetherington + + * Fix error when examining files with embedded subtitles in some cases (#969). + 2016-10-04 Carl Hetherington * Version 2.9.30 released. diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 4b95666b8..af6c8e167 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -282,21 +282,27 @@ FFmpeg::subtitle_id (AVSubtitle const & sub) digester.add (sub.pts); for (unsigned int i = 0; i < sub.num_rects; ++i) { AVSubtitleRect* rect = sub.rects[i]; - digester.add (rect->x); - digester.add (rect->y); - digester.add (rect->w); - digester.add (rect->h); + if (rect->type == SUBTITLE_BITMAP) { + digester.add (rect->x); + digester.add (rect->y); + digester.add (rect->w); + digester.add (rect->h); #ifdef DCPOMATIC_HAVE_AVSUBTITLERECT_PICT - int const line = rect->pict.linesize[0]; - for (int j = 0; j < rect->h; ++j) { - digester.add (rect->pict.data[0] + j * line, line); - } + int const line = rect->pict.linesize[0]; + for (int j = 0; j < rect->h; ++j) { + digester.add (rect->pict.data[0] + j * line, line); + } #else - int const line = rect->linesize[0]; - for (int j = 0; j < rect->h; ++j) { - digester.add (rect->data[0] + j * line, line); - } + int const line = rect->linesize[0]; + for (int j = 0; j < rect->h; ++j) { + digester.add (rect->data[0] + j * line, line); + } #endif + } else if (rect->type == SUBTITLE_TEXT) { + digester.add (string (rect->text)); + } else if (rect->type == SUBTITLE_ASS) { + digester.add (string (rect->ass)); + } } return digester.get (); } diff --git a/src/lib/ffmpeg_subtitle_stream.cc b/src/lib/ffmpeg_subtitle_stream.cc index 627b0fef1..cf3a8c0f2 100644 --- a/src/lib/ffmpeg_subtitle_stream.cc +++ b/src/lib/ffmpeg_subtitle_stream.cc @@ -128,6 +128,7 @@ FFmpegSubtitleStream::add_image_subtitle (string id, ContentTimePeriod period) void FFmpegSubtitleStream::add_text_subtitle (string id, ContentTimePeriod period) { + cout << id << " " << to_string(period.from) << " " << to_string(period.to) << "\n"; DCPOMATIC_ASSERT (_text_subtitles.find (id) == _text_subtitles.end ()); _text_subtitles[id] = period; }