summaryrefslogtreecommitdiff
path: root/src/lib/film.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-04-23 00:11:38 +0200
committerCarl Hetherington <cth@carlh.net>2020-04-24 00:46:31 +0200
commitcef7a679a59044a5c807768042deecfd56ec6fc2 (patch)
treeb0e020a2a70db228df0e96fd85b63a84d7d69b64 /src/lib/film.cc
parent87d5a977da0696fbe73b96b2679b7cbb471e7255 (diff)
Add subtitle analysis so that the outline of all subtitles
in a piece of content can be overlaid onto the preview (#1233).
Diffstat (limited to 'src/lib/film.cc')
-rw-r--r--src/lib/film.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index a89d58a1f..a24e9aa30 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -54,6 +54,8 @@
#include "cinema.h"
#include "change_signaller.h"
#include "check_content_change_job.h"
+#include "ffmpeg_subtitle_stream.h"
+#include "font.h"
#include <libcxml/cxml.h>
#include <dcp/cpl.h>
#include <dcp/certificate_chain.h>
@@ -302,6 +304,39 @@ Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
return p;
}
+
+boost::filesystem::path
+Film::subtitle_analysis_path (shared_ptr<const Content> content) const
+{
+ boost::filesystem::path p = dir ("analysis");
+
+ Digester digester;
+ digester.add (content->digest());
+
+ if (!content->text.empty()) {
+ shared_ptr<TextContent> tc = content->text.front();
+ digester.add (tc->x_scale());
+ digester.add (tc->y_scale());
+ BOOST_FOREACH (shared_ptr<dcpomatic::Font> i, tc->fonts()) {
+ digester.add (i->id());
+ }
+ if (tc->effect()) {
+ digester.add (tc->effect().get());
+ }
+ digester.add (tc->line_spacing());
+ digester.add (tc->outline_width());
+ }
+
+ shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent>(content);
+ if (fc) {
+ digester.add (fc->subtitle_stream()->identifier());
+ }
+
+ p /= digester.get ();
+ return p;
+}
+
+
/** Add suitable Jobs to the JobManager to create a DCP for this Film.
* @param gui true if this is being called from a GUI tool.
* @param check true to check the content in the project for changes before making the DCP.