summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-06 14:22:33 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-06 14:22:33 +0000
commitf9819a16d40403af3da08263ee6bb3b5a99d650f (patch)
treeb59fdf315a46309f6d6ef324388b0f4530cff7e0 /src
parent3a51cc23de37ff0821009af780ef56e0e28394f7 (diff)
Give a warning on make DCP if it seems unlikely that the disk will have enough space to store the finished DCP (#92).
Diffstat (limited to 'src')
-rw-r--r--src/lib/film.cc25
-rw-r--r--src/lib/film.h3
-rw-r--r--src/tools/dcpomatic.cc9
-rw-r--r--src/wx/properties_dialog.cc2
4 files changed, 38 insertions, 1 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 1bf35cc5f..edd47c6d0 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -974,3 +974,28 @@ Film::make_kdms (
return kdms;
}
+
+/** @return The approximate disk space required to encode a DCP of this film with the
+ * current settings, in bytes.
+ */
+uint64_t
+Film::required_disk_space () const
+{
+ return uint64_t (j2k_bandwidth() / 8) * length() / TIME_HZ;
+}
+
+/** This method checks the disk that the Film is on and tries to decide whether or not
+ * there will be enough space to make a DCP for it. If so, true is returned; if not,
+ * false is returned and required and availabe are filled in with the amount of disk space
+ * required and available respectively (in Gb).
+ *
+ * Note: the decision made by this method isn't, of course, 100% reliable.
+ */
+bool
+Film::should_be_enough_disk_space (double& required, double& available) const
+{
+ boost::filesystem::space_info s = boost::filesystem::space (internal_video_mxf_dir ());
+ required = double (required_disk_space ()) / 1073741824.0f;
+ available = double (s.available) / 1073741824.0f;
+ return (available - required) > 1;
+}
diff --git a/src/lib/film.h b/src/lib/film.h
index e318f7724..0a747193e 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -108,6 +108,9 @@ public:
Time video_frames_to_time (OutputVideoFrame) const;
Time audio_frames_to_time (OutputAudioFrame) const;
+ uint64_t required_disk_space () const;
+ bool should_be_enough_disk_space (double &, double &) const;
+
/* Proxies for some Playlist methods */
ContentList content () const;
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 891c4623c..7cbb08725 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -442,6 +442,15 @@ private:
void jobs_make_dcp ()
{
+ double required;
+ double available;
+
+ if (!film->should_be_enough_disk_space (required, available)) {
+ if (!confirm_dialog (this, wxString::Format (_("The DCP for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. Do you want to continue anyway?"), required, available))) {
+ return;
+ }
+ }
+
JobWrapper::make_dcp (this, film);
}
diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc
index f3f841a43..11510cd0f 100644
--- a/src/wx/properties_dialog.cc
+++ b/src/wx/properties_dialog.cc
@@ -52,7 +52,7 @@ PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr<Film> film)
_table->Add (_encoded, 1, wxALIGN_CENTER_VERTICAL);
_frames->SetLabel (std_to_wx (lexical_cast<string> (_film->time_to_video_frames (_film->length()))));
- double const disk = ((double) _film->j2k_bandwidth() / 8) * _film->length() / (TIME_HZ * 1073741824.0f);
+ double const disk = double (_film->required_disk_space()) / 1073741824.0f;
stringstream s;
s << fixed << setprecision (1) << disk << wx_to_std (_("Gb"));
_disk->SetLabel (std_to_wx (s.str ()));