summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-06 11:07:20 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-06 11:07:20 +0000
commitc7763b01172ec854d80199000e9536393806e882 (patch)
treebeb795804bf37bb643211d8c5989b9b28de22c6c /src/lib
parent1d49c6b90bc8f6a0e5e7ff0a2e7aeae3e3043a6d (diff)
parent89f66ac25a5fffa04cf3abc569a0b4eaf7259320 (diff)
Merge branch 'master' into windows-debug
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/image_examiner.cc34
-rw-r--r--src/lib/writer.cc41
2 files changed, 34 insertions, 41 deletions
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
index 2d150583a..17064fd45 100644
--- a/src/lib/image_examiner.cc
+++ b/src/lib/image_examiner.cc
@@ -41,36 +41,10 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
, _image_content (content)
, _video_length (0)
{
- list<unsigned int> frames;
- size_t const N = content->number_of_paths ();
-
- for (size_t i = 0; i < N; ++i) {
- boost::filesystem::path const p = content->path (i);
- try {
- frames.push_back (lexical_cast<int> (p.stem().string()));
- } catch (bad_lexical_cast &) {
- /* We couldn't turn that filename into a number; never mind */
- }
-
- if (!_video_size) {
- using namespace MagickCore;
- Magick::Image* image = new Magick::Image (p.string());
- _video_size = libdcp::Size (image->columns(), image->rows());
- delete image;
- }
-
- job->set_progress (float (i) / N);
- }
-
- frames.sort ();
-
- if (N > 1 && frames.front() != 0 && frames.front() != 1) {
- throw StringError (String::compose (_("first frame in moving image directory is number %1"), frames.front ()));
- }
-
- if (N > 1 && frames.back() != frames.size() && frames.back() != (frames.size() - 1)) {
- throw StringError (String::compose (_("there are %1 images in the directory but the last one is number %2"), frames.size(), frames.back ()));
- }
+ using namespace MagickCore;
+ Magick::Image* image = new Magick::Image (content->path(0).string());
+ _video_size = libdcp::Size (image->columns(), image->rows());
+ delete image;
if (content->still ()) {
_video_length = Config::instance()->default_still_length() * video_frame_rate();
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 15732b131..5fc848195 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -92,8 +92,11 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j)
}
_picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0);
-
- _sound_asset.reset (new libdcp::SoundAsset (_film->dir (_film->dcp_name()), _film->audio_mxf_filename ()));
+
+ /* Write the sound asset into the film directory so that we leave the creation
+ of the DCP directory until the last minute.
+ */
+ _sound_asset.reset (new libdcp::SoundAsset (_film->dir ("."), _film->audio_mxf_filename ()));
_sound_asset->set_edit_rate (_film->video_frame_rate ());
_sound_asset->set_channels (_film->audio_channels ());
_sound_asset->set_sampling_rate (_film->audio_frame_rate ());
@@ -348,20 +351,19 @@ Writer::finish ()
_picture_asset->set_duration (frames);
/* Hard-link the video MXF into the DCP */
-
- boost::filesystem::path from;
- from /= _film->internal_video_mxf_dir();
- from /= _film->internal_video_mxf_filename();
+ boost::filesystem::path video_from;
+ video_from /= _film->internal_video_mxf_dir();
+ video_from /= _film->internal_video_mxf_filename();
- boost::filesystem::path to;
- to /= _film->dir (_film->dcp_name());
- to /= _film->video_mxf_filename ();
+ boost::filesystem::path video_to;
+ video_to /= _film->dir (_film->dcp_name());
+ video_to /= _film->video_mxf_filename ();
boost::system::error_code ec;
- boost::filesystem::create_hard_link (from, to, ec);
+ boost::filesystem::create_hard_link (video_from, video_to, ec);
if (ec) {
/* hard link failed; copy instead */
- boost::filesystem::copy_file (from, to);
+ boost::filesystem::copy_file (video_from, video_to);
_film->log()->log ("Hard-link failed; fell back to copying");
}
@@ -369,6 +371,23 @@ Writer::finish ()
_picture_asset->set_directory (_film->dir (_film->dcp_name ()));
_picture_asset->set_file_name (_film->video_mxf_filename ());
+
+ /* Move the audio MXF into the DCP */
+
+ boost::filesystem::path audio_from;
+ audio_from /= _film->dir (".");
+ audio_from /= _film->audio_mxf_filename ();
+
+ boost::filesystem::path audio_to;
+ audio_to /= _film->dir (_film->dcp_name ());
+ audio_to /= _film->audio_mxf_filename ();
+
+ boost::filesystem::rename (audio_from, audio_to, ec);
+ if (ec) {
+ throw FileError (String::compose (_("could not move audio MXF into the DCP (%1)"), ec.value ()), audio_from);
+ }
+
+ _sound_asset->set_directory (_film->dir (_film->dcp_name ()));
_sound_asset->set_duration (frames);
libdcp::DCP dcp (_film->dir (_film->dcp_name()));