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.
21 #include "exceptions.h"
23 #include "sound_mxf.h"
24 #include "picture_mxf.h"
25 #include "subtitle_content.h"
26 #include "reel_picture_asset.h"
27 #include "reel_sound_asset.h"
28 #include "reel_subtitle_asset.h"
29 #include "subtitle_string.h"
33 #include <boost/filesystem.hpp>
34 #include <boost/foreach.hpp>
42 using boost::shared_ptr;
48 cerr << "Syntax: " << n << " [options] <DCP>\n"
49 << " -s, --subtitles list all subtitles\n"
50 << " -k, --keep-going carry on in the event of errors, if possible\n"
51 << " --ignore-missing-assets ignore missing asset files\n";
55 main_picture (shared_ptr<Reel> reel)
57 if (reel->main_picture() && reel->main_picture()->mxf()) {
59 << reel->main_picture()->mxf()->size().width
61 << reel->main_picture()->mxf()->size().height << "\n";
66 main_sound (shared_ptr<Reel> reel)
68 if (reel->main_sound() && reel->main_sound()->mxf()) {
70 << reel->main_sound()->mxf()->channels()
72 << reel->main_sound()->mxf()->sampling_rate() << "Hz\n";
77 main_subtitle (shared_ptr<Reel> reel, bool list_subtitles)
79 if (!reel->main_subtitle()) {
83 list<SubtitleString> subs = reel->main_subtitle()->subtitle_content()->subtitles ();
84 cout << " Subtitle: " << subs.size() << " subtitles in " << reel->main_subtitle()->subtitle_content()->language() << "\n";
86 BOOST_FOREACH (SubtitleString const& k, subs) {
93 main (int argc, char* argv[])
95 bool subtitles = false;
96 bool keep_going = false;
97 bool ignore_missing_assets = false;
101 static struct option long_options[] = {
102 { "version", no_argument, 0, 'v' },
103 { "help", no_argument, 0, 'h' },
104 { "subtitles", no_argument, 0, 's' },
105 { "keep-going", no_argument, 0, 'k' },
106 { "ignore-missing-assets", no_argument, 0, 'A' },
110 int c = getopt_long (argc, argv, "vhskA", long_options, &option_index);
118 cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
130 ignore_missing_assets = true;
135 if (argc <= optind || argc > (optind + 1)) {
140 if (!boost::filesystem::exists (argv[optind])) {
141 cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
146 DCP::ReadErrors errors;
148 dcp = new DCP (argv[optind]);
149 dcp->read (keep_going, &errors);
150 } catch (FileError& e) {
151 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
153 } catch (DCPReadError& e) {
154 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
158 cout << "DCP: " << boost::filesystem::path(argv[optind]).filename().string() << "\n";
160 dcp::filter_errors (errors, ignore_missing_assets);
161 for (DCP::ReadErrors::const_iterator i = errors.begin(); i != errors.end(); ++i) {
162 cerr << "Error: " << (*i)->what() << "\n";
165 list<shared_ptr<CPL> > cpls = dcp->cpls ();
167 for (list<shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
168 cout << " CPL: " << (*i)->annotation_text() << "\n";
170 list<shared_ptr<Reel> > reels = (*i)->reels ();
173 for (list<shared_ptr<Reel> >::const_iterator j = reels.begin(); j != reels.end(); ++j) {
174 cout << " Reel " << R << "\n";
178 } catch (UnresolvedRefError& e) {
180 if (!ignore_missing_assets) {
181 cerr << e.what() << " (for main picture)\n";
190 } catch (UnresolvedRefError& e) {
192 if (!ignore_missing_assets) {
193 cerr << e.what() << " (for main sound)\n";
201 main_subtitle (*j, subtitles);
202 } catch (UnresolvedRefError& e) {
204 if (!ignore_missing_assets) {
205 cerr << e.what() << " (for main subtitle)\n";