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.
20 /** @file src/make_dcp_job.cc
21 * @brief A job to create DCPs.
24 #include <boost/filesystem.hpp>
26 #include <libavutil/pixdesc.h>
28 #include "make_dcp_job.h"
29 #include "film_state.h"
30 #include "dcp_content_type.h"
31 #include "exceptions.h"
34 using namespace boost;
36 /** @param s FilmState of the Film we are making the DCP for.
40 MakeDCPJob::MakeDCPJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
41 : ShellCommandJob (s, o, l)
47 MakeDCPJob::name () const
50 s << "Make DCP for " << _fs->name;
57 set_progress_unknown ();
59 string const dcp_path = _fs->dir (_fs->name);
61 /* Check that we have our prerequisites */
63 if (!filesystem::exists (filesystem::path (_fs->file ("video.mxf")))) {
64 throw EncodeError ("missing video.mxf");
67 bool const have_audio = filesystem::exists (filesystem::path (_fs->file ("audio.mxf")));
69 /* Remove any old DCP */
70 filesystem::remove_all (dcp_path);
72 /* Re-make the DCP directory */
76 c << "cd \"" << dcp_path << "\" && "
77 << " opendcp_xml -d -a " << _fs->name
78 << " -t \"" << _fs->name << "\""
79 << " -k " << _fs->dcp_content_type->opendcp_name()
80 << " --reel \"" << _fs->file ("video.mxf") << "\"";
83 c << " \"" << _fs->file ("audio.mxf") << "\"";
88 filesystem::rename (filesystem::path (_fs->file ("video.mxf")), filesystem::path (dcp_path + "/video.mxf"));
90 filesystem::rename (filesystem::path (_fs->file ("audio.mxf")), filesystem::path (dcp_path + "/audio.mxf"));