2 Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <boost/filesystem.hpp>
25 #include "exceptions.h"
27 #include "sound_mxf.h"
28 #include "picture_mxf.h"
29 #include "subtitle_content.h"
30 #include "reel_picture_asset.h"
31 #include "reel_sound_asset.h"
32 #include "reel_subtitle_asset.h"
33 #include "subtitle_string.h"
41 using boost::shared_ptr;
47 cerr << "Syntax: " << n << " [options] <DCP>\n"
48 << " -s, --subtitles list all subtitles\n"
49 << " -k, --keep-going carry on in the event of errors, if possible\n"
50 << " --ignore-missing-assets ignore missing asset files\n";
54 main_picture (shared_ptr<Reel> reel)
56 if (reel->main_picture() && reel->main_picture()->mxf()) {
58 << reel->main_picture()->mxf()->size().width
60 << reel->main_picture()->mxf()->size().height << "\n";
65 main_sound (shared_ptr<Reel> reel)
67 if (reel->main_sound() && reel->main_sound()->mxf()) {
69 << reel->main_sound()->mxf()->channels()
71 << reel->main_sound()->mxf()->sampling_rate() << "Hz\n";
76 main_subtitle (shared_ptr<Reel> reel, bool list_subtitles)
78 if (!reel->main_subtitle()) {
82 list<shared_ptr<SubtitleString> > subs = reel->main_subtitle()->subtitle_content()->subtitles ();
83 cout << " Subtitle: " << subs.size() << " subtitles in " << reel->main_subtitle()->subtitle_content()->language() << "\n";
85 for (list<shared_ptr<SubtitleString> >::const_iterator k = subs.begin(); k != subs.end(); ++k) {
86 cout << " " << (*k)->text() << "\n";
88 << "font:" << (*k)->font() << "; "
89 << "italic:" << (*k)->italic() << "; "
90 << "color:" << (*k)->color() << "; "
91 << "in:" << (*k)->in() << "; "
92 << "out:" << (*k)->out() << "; "
93 << "v_position:" << (*k)->v_position() << "; "
94 << "v_align:" << (*k)->v_align() << "; "
95 << "effect:" << (*k)->effect() << "; "
96 << "effect_color:" << (*k)->effect_color() << "; "
97 << "fade_up_time:" << (*k)->fade_up_time() << "; "
98 << "fade_down_time:" << (*k)->fade_down_time() << "; "
99 << "size: " << (*k)->size() << "\n";
105 main (int argc, char* argv[])
107 bool subtitles = false;
108 bool keep_going = false;
109 bool ignore_missing_assets = false;
111 int option_index = 0;
113 static struct option long_options[] = {
114 { "version", no_argument, 0, 'v' },
115 { "help", no_argument, 0, 'h' },
116 { "subtitles", no_argument, 0, 's' },
117 { "keep-going", no_argument, 0, 'k' },
118 { "ignore-missing-assets", no_argument, 0, 'A' },
122 int c = getopt_long (argc, argv, "vhskA", long_options, &option_index);
130 cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
142 ignore_missing_assets = true;
147 if (argc <= optind || argc > (optind + 1)) {
152 if (!boost::filesystem::exists (argv[optind])) {
153 cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
158 DCP::ReadErrors errors;
160 dcp = new DCP (argv[optind]);
161 dcp->read (keep_going, &errors);
162 } catch (FileError& e) {
163 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
165 } catch (DCPReadError& e) {
166 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
170 cout << "DCP: " << boost::filesystem::path(argv[optind]).filename().string() << "\n";
172 dcp::filter_errors (errors, ignore_missing_assets);
173 for (DCP::ReadErrors::const_iterator i = errors.begin(); i != errors.end(); ++i) {
174 cerr << "Error: " << (*i)->what() << "\n";
177 list<shared_ptr<CPL> > cpls = dcp->cpls ();
179 for (list<shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
180 cout << " CPL: " << (*i)->annotation_text() << "\n";
182 list<shared_ptr<Reel> > reels = (*i)->reels ();
185 for (list<shared_ptr<Reel> >::const_iterator j = reels.begin(); j != reels.end(); ++j) {
186 cout << " Reel " << R << "\n";
190 } catch (UnresolvedRefError& e) {
192 if (!ignore_missing_assets) {
193 cerr << e.what() << " (for main picture)\n";
202 } catch (UnresolvedRefError& e) {
204 if (!ignore_missing_assets) {
205 cerr << e.what() << " (for main sound)\n";
213 main_subtitle (*j, subtitles);
214 } catch (UnresolvedRefError& e) {
216 if (!ignore_missing_assets) {
217 cerr << e.what() << " (for main subtitle)\n";