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"
40 using boost::shared_ptr;
46 cerr << "Syntax: " << n << " [options] <DCP>\n"
47 << " -s, --subtitles list all subtitles\n"
48 << " -k, --keep-going carry on in the event of errors, if possible\n";
52 main_picture (shared_ptr<Reel> reel)
54 if (reel->main_picture() && reel->main_picture()->mxf()) {
56 << reel->main_picture()->mxf()->size().width
58 << reel->main_picture()->mxf()->size().height << "\n";
63 main_sound (shared_ptr<Reel> reel)
65 if (reel->main_sound() && reel->main_sound()->mxf()) {
67 << reel->main_sound()->mxf()->channels()
69 << reel->main_sound()->mxf()->sampling_rate() << "Hz\n";
74 main_subtitle (shared_ptr<Reel> reel, bool list_subtitles)
76 if (!reel->main_subtitle()) {
80 list<shared_ptr<SubtitleString> > subs = reel->main_subtitle()->subtitle_content()->subtitles ();
81 cout << " Subtitle: " << subs.size() << " subtitles in " << reel->main_subtitle()->subtitle_content()->language() << "\n";
83 for (list<shared_ptr<SubtitleString> >::const_iterator k = subs.begin(); k != subs.end(); ++k) {
84 cout << " " << (*k)->text() << "\n";
86 << "font:" << (*k)->font() << "; "
87 << "italic:" << (*k)->italic() << "; "
88 << "color:" << (*k)->color() << "; "
89 << "in:" << (*k)->in() << "; "
90 << "out:" << (*k)->out() << "; "
91 << "v_position:" << (*k)->v_position() << "; "
92 << "v_align:" << (*k)->v_align() << "; "
93 << "effect:" << (*k)->effect() << "; "
94 << "effect_color:" << (*k)->effect_color() << "; "
95 << "fade_up_time:" << (*k)->fade_up_time() << "; "
96 << "fade_down_time:" << (*k)->fade_down_time() << "; "
97 << "size: " << (*k)->size() << "\n";
103 main (int argc, char* argv[])
105 bool subtitles = false;
106 bool keep_going = false;
108 int option_index = 0;
110 static struct option long_options[] = {
111 { "version", no_argument, 0, 'v'},
112 { "help", no_argument, 0, 'h'},
113 { "subtitles", no_argument, 0, 's'},
114 { "keep-going", no_argument, 0, 'k'},
118 int c = getopt_long (argc, argv, "vhsk", long_options, &option_index);
126 cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
140 if (argc <= optind || argc > (optind + 1)) {
145 if (!boost::filesystem::exists (argv[optind])) {
146 cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
151 list<shared_ptr<DCPReadError> > errors;
153 dcp = new DCP (argv[optind]);
154 dcp->read (keep_going, &errors);
155 } catch (FileError& e) {
156 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
158 } catch (DCPReadError& e) {
159 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
163 cout << "DCP: " << boost::filesystem::path(argv[optind]).filename().string() << "\n";
165 for (list<shared_ptr<DCPReadError> >::const_iterator i = errors.begin(); i != errors.end(); ++i) {
166 cerr << "Error: " << (*i)->what() << "\n";
169 list<shared_ptr<CPL> > cpls = dcp->cpls ();
171 for (list<shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
172 cout << " CPL: " << (*i)->annotation_text() << "\n";
174 list<shared_ptr<Reel> > reels = (*i)->reels ();
177 for (list<shared_ptr<Reel> >::const_iterator j = reels.begin(); j != reels.end(); ++j) {
178 cout << " Reel " << R << "\n";
182 } catch (UnresolvedRefError& e) {
184 cerr << e.what() << " (for main picture)\n";
192 } catch (UnresolvedRefError& e) {
194 cerr << e.what() << " (for main sound)\n";
201 main_subtitle (*j, subtitles);
202 } catch (UnresolvedRefError& e) {
204 cerr << e.what() << " (for main subtitle)\n";