+2015-01-04 Carl Hetherington <cth@carlh.net>
+
+ * Fix loading of SMPTE XML subtitles which
+ are not MXF-wrapped.
+
2014-12-14 Carl Hetherington <cth@carlh.net>
* Version 2.0.25 released.
string ext = path.extension().string ();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-
+
if (valid_image_file (path)) {
content.reset (new ImageContent (film, path));
} else if (SndfileContent::valid_file (path)) {
content.reset (new SubRipContent (film, path));
} else if (ext == ".xml") {
content.reset (new DCPSubtitleContent (film, path));
- } else {
+ } else if (ext == ".mxf") {
+ /* Try to read this .mxf as a subtitle file; if we fail, we fall back
+ to using FFmpeg below.
+ */
+ try {
+ content.reset (new DCPSubtitleContent (film, path));
+ } catch (...) {
+
+ }
+ }
+
+ if (!content) {
content.reset (new FFmpegContent (film, path));
}
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "dcp_subtitle.h"
+#include "exceptions.h"
+#include <dcp/interop_subtitle_content.h>
+#include <dcp/smpte_subtitle_content.h>
+
+#include "i18n.h"
+
+using boost::shared_ptr;
+
+shared_ptr<dcp::SubtitleContent>
+DCPSubtitle::load (boost::filesystem::path file) const
+{
+ shared_ptr<dcp::SubtitleContent> sc;
+
+ try {
+ sc.reset (new dcp::InteropSubtitleContent (file));
+ } catch (...) {
+
+ }
+
+ if (!sc) {
+ try {
+ sc.reset (new dcp::SMPTESubtitleContent (file, true));
+ } catch (...) {
+
+ }
+ }
+
+ if (!sc) {
+ try {
+ sc.reset (new dcp::SMPTESubtitleContent (file, false));
+ } catch (...) {
+
+ }
+ }
+
+ if (!sc) {
+ throw FileError (_("Could not read subtitles"), file);
+ }
+
+ return sc;
+}
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef DCPOMATIC_SRC_LIB_DCP_SUBTITLE_H
+#define DCPOMATIC_SRC_LIB_DCP_SUBTITLE_H
+
+#include <boost/shared_ptr.hpp>
+#include <boost/filesystem.hpp>
+
+namespace dcp {
+ class SubtitleContent;
+}
+
+class DCPSubtitle
+{
+protected:
+ boost::shared_ptr<dcp::SubtitleContent> load (boost::filesystem::path) const;
+};
+
+#endif
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "font.h"
#include "dcp_subtitle_content.h"
#include <dcp/interop_subtitle_content.h>
+#include <dcp/smpte_subtitle_content.h>
#include <dcp/interop_load_font.h>
#include <dcp/raw_convert.h>
DCPSubtitleContent::examine (shared_ptr<Job> job, bool calculate_digest)
{
Content::examine (job, calculate_digest);
-
- dcp::InteropSubtitleContent sc (path (0));
+ shared_ptr<dcp::SubtitleContent> sc = load (path (0));
+
boost::mutex::scoped_lock lm (_mutex);
- _subtitle_language = sc.language ();
- _length = DCPTime::from_seconds (sc.latest_subtitle_out().to_seconds ());
+ _subtitle_language = sc->language ();
+ _length = DCPTime::from_seconds (sc->latest_subtitle_out().to_seconds ());
- list<shared_ptr<dcp::InteropLoadFont> > fonts = sc.load_font_nodes ();
- for (list<shared_ptr<dcp::InteropLoadFont> >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
+ list<shared_ptr<dcp::LoadFont> > fonts = sc->load_font_nodes ();
+ for (list<shared_ptr<dcp::LoadFont> >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
_fonts.push_back (shared_ptr<Font> (new Font ((*i)->id)));
}
}
*/
#include "subtitle_content.h"
+#include "dcp_subtitle.h"
-class DCPSubtitleContent : public SubtitleContent
+class DCPSubtitleContent : public SubtitleContent, public DCPSubtitle
{
public:
DCPSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content)
: SubtitleDecoder (content)
{
- dcp::InteropSubtitleContent c (content->path (0));
- _subtitles = c.subtitles ();
+ shared_ptr<dcp::SubtitleContent> c (load (content->path (0)));
+ _subtitles = c->subtitles ();
_next = _subtitles.begin ();
}
*/
#include "subtitle_decoder.h"
+#include "dcp_subtitle.h"
class DCPSubtitleContent;
-class DCPSubtitleDecoder : public SubtitleDecoder
+class DCPSubtitleDecoder : public SubtitleDecoder, public DCPSubtitle
{
public:
DCPSubtitleDecoder (boost::shared_ptr<const DCPSubtitleContent>);
dcp_content_type.cc
dcp_decoder.cc
dcp_examiner.cc
+ dcp_subtitle.cc
dcp_subtitle_content.cc
dcp_subtitle_decoder.cc
dcp_video.cc