2 Copyright (C) 2012 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.
23 #include <libdcp/version.h>
27 #include "transcode_job.h"
28 #include "job_manager.h"
29 #include "ab_transcode_job.h"
43 using boost::shared_ptr;
48 cerr << "Syntax: " << n << " [OPTION] <FILM>\n"
49 << " -v, --version show DVD-o-matic version\n"
50 << " -h, --help show this help\n"
51 << " -d, --deps list DVD-o-matic dependency details and quit\n"
52 << " -n, --no-progress do not print progress to stdout\n"
53 << " -r, --no-remote do not use any remote servers\n"
55 << "<FILM> is the film directory.\n";
59 main (int argc, char* argv[])
63 bool no_remote = false;
68 static struct option long_options[] = {
69 { "version", no_argument, 0, 'v'},
70 { "help", no_argument, 0, 'h'},
71 { "deps", no_argument, 0, 'd'},
72 { "no-progress", no_argument, 0, 'n'},
73 { "no-remote", no_argument, 0, 'r'},
74 { "log-level", required_argument, 0, 'l' },
78 int c = getopt_long (argc, argv, "vhdnrl:", long_options, &option_index);
86 cout << "dvdomatic version " << dvdomatic_version << " " << dvdomatic_git_commit << "\n";
92 cout << dependency_version_summary () << "\n";
101 log_level = atoi (optarg);
106 if (optind >= argc) {
111 film_dir = argv[optind];
116 Config::instance()->set_servers (vector<ServerDescription*> ());
119 cout << "DVD-o-matic " << dvdomatic_version << " git " << dvdomatic_git_commit;
121 if (gethostname (buf, 256) == 0) {
122 cout << " on " << buf;
126 shared_ptr<Film> film;
128 film.reset (new Film (film_dir, true));
129 } catch (std::exception& e) {
130 cerr << argv[0] << ": error reading film `" << film_dir << "' (" << e.what() << ")\n";
134 film->log()->set_level ((Log::Level) log_level);
137 if (film->dcp_ab()) {
140 cout << "DCP for " << film->name() << "\n";
141 cout << "Content: " << film->content() << "\n";
142 pair<string, string> const f = Filter::ffmpeg_strings (film->filters ());
143 cout << "Filters: " << f.first << " " << f.second << "\n";
147 bool should_stop = false;
150 while (!should_stop) {
154 list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
156 if (!first && progress) {
157 cout << "\033[" << jobs.size() << "A";
164 int finished_in_error = 0;
166 for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
168 cout << (*i)->name() << ": ";
170 float const p = (*i)->overall_progress ();
173 cout << (*i)->status() << " \n";
175 cout << ": Running \n";
179 if (!(*i)->finished ()) {
183 if ((*i)->finished_in_error ()) {
188 if (!progress && (*i)->finished_in_error ()) {
189 /* We won't see this error if we haven't been showing progress,
192 cout << (*i)->status() << "\n";
196 if (unfinished == 0 || finished_in_error != 0) {
201 return error ? EXIT_FAILURE : EXIT_SUCCESS;