summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-04 00:26:56 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-06 23:10:58 +0200
commitfcba100f0dfd1d4214291abb76f22ebd696c24d4 (patch)
treed31225dbe78d324615a55e0abdbd0f6b1740e2c4
parent7b30ec45f8d3d2881d633356058628373eb47057 (diff)
Preserve export video settings in the config (#2259).
-rw-r--r--src/lib/config.cc7
-rw-r--r--src/lib/config.h38
-rw-r--r--src/lib/export_config.cc135
-rw-r--r--src/lib/export_config.h79
-rw-r--r--src/lib/wscript1
-rw-r--r--src/wx/export_video_file_dialog.cc63
-rw-r--r--src/wx/export_video_file_dialog.h4
m---------test/data0
8 files changed, 305 insertions, 22 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 3661d8ba5..caea995be 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -79,6 +79,7 @@ Config::Config ()
/* DKDMs are not considered a thing to reset on set_defaults() */
: _dkdms (new DKDMGroup ("root"))
, _default_kdm_duration (1, RoughDuration::Unit::WEEKS)
+ , _export(this)
{
set_defaults ();
}
@@ -203,6 +204,8 @@ Config::set_defaults ()
set_kdm_email_to_default ();
set_notification_email_to_default ();
set_cover_sheet_to_default ();
+
+ _export.set_defaults();
}
void
@@ -589,6 +592,8 @@ try
}
_auto_crop_threshold = f.optional_number_child<double>("AutoCropThreshold").get_value_or(0.1);
+ _export.read(f.optional_node_child("Export"));
+
if (boost::filesystem::exists (_cinemas_file)) {
cxml::Document f ("Cinemas");
f.read_file (_cinemas_file);
@@ -1026,6 +1031,8 @@ Config::write_config () const
root->add_child("DefaultKDMType")->add_child_text(dcp::formulation_to_string(_default_kdm_type));
root->add_child("AutoCropThreshold")->add_child_text(raw_convert<string>(_auto_crop_threshold));
+ _export.write(root->add_child("Export"));
+
auto target = config_write_file();
try {
diff --git a/src/lib/config.h b/src/lib/config.h
index e425a976c..9c3650f8d 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -28,6 +28,7 @@
#include "audio_mapping.h"
+#include "export_config.h"
#include "rough_duration.h"
#include "state.h"
#include "types.h"
@@ -1113,6 +1114,10 @@ public:
maybe_set (_auto_crop_threshold, threshold, AUTO_CROP_THRESHOLD);
}
+ ExportConfig& export_config() {
+ return _export;
+ }
+
void changed (Property p = OTHER);
boost::signals2::signal<void (Property)> Changed;
/** Emitted if read() failed on an existing Config file. There is nothing
@@ -1158,21 +1163,6 @@ public:
static boost::filesystem::path config_read_file ();
static boost::filesystem::path config_write_file ();
-private:
- Config ();
- void read () override;
- void set_defaults ();
- void set_kdm_email_to_default ();
- void set_notification_email_to_default ();
- void set_cover_sheet_to_default ();
- void read_cinemas (cxml::Document const & f);
- void read_dkdm_recipients (cxml::Document const & f);
- std::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
- boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
- void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
- void clean_history_internal (std::vector<boost::filesystem::path>& h);
- void backup ();
-
template <class T>
void maybe_set (T& member, T new_value, Property prop = OTHER) {
if (member == new_value) {
@@ -1191,6 +1181,21 @@ private:
changed (prop);
}
+private:
+ Config ();
+ void read () override;
+ void set_defaults ();
+ void set_kdm_email_to_default ();
+ void set_notification_email_to_default ();
+ void set_cover_sheet_to_default ();
+ void read_cinemas (cxml::Document const & f);
+ void read_dkdm_recipients (cxml::Document const & f);
+ std::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
+ boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
+ void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
+ void clean_history_internal (std::vector<boost::filesystem::path>& h);
+ void backup ();
+
/** number of threads which a master DoM should use for J2K encoding on the local machine */
int _master_encoding_threads;
/** number of threads which a server should use for J2K encoding on the local machine */
@@ -1336,10 +1341,13 @@ private:
RoughDuration _default_kdm_duration;
double _auto_crop_threshold;
+ ExportConfig _export;
+
static int const _current_version;
/** Singleton instance, or 0 */
static Config* _instance;
};
+
#endif
diff --git a/src/lib/export_config.cc b/src/lib/export_config.cc
new file mode 100644
index 000000000..6c9807935
--- /dev/null
+++ b/src/lib/export_config.cc
@@ -0,0 +1,135 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "config.h"
+#include "export_config.h"
+#include <dcp/raw_convert.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <libxml++/libxml++.h>
+LIBDCP_ENABLE_WARNINGS
+
+
+using std::string;
+
+
+ExportConfig::ExportConfig(Config* parent)
+ : _config(parent)
+{
+
+}
+
+
+void
+ExportConfig::set_defaults()
+{
+ _format = ExportFormat::PRORES;
+ _mixdown_to_stereo = false;
+ _split_reels = false;
+ _split_streams = false;
+ _x264_crf = 23;
+}
+
+
+void
+ExportConfig::read(cxml::ConstNodePtr node)
+{
+ if (!node) {
+ set_defaults();
+ return;
+ }
+
+ auto const format = node->string_child("Format");
+
+ if (format == "subtitles-dcp") {
+ _format = ExportFormat::SUBTITLES_DCP;
+ } else if (format == "h264-aac") {
+ _format = ExportFormat::H264_AAC;
+ } else {
+ _format = ExportFormat::PRORES;
+ }
+
+ _mixdown_to_stereo = node->bool_child("MixdownToStereo");
+ _split_reels = node->bool_child("SplitReels");
+ _split_streams = node->bool_child("SplitStreams");
+ _x264_crf = node->number_child<int>("X264CRF");
+}
+
+
+void
+ExportConfig::write(xmlpp::Element* node) const
+{
+ string name;
+
+ switch (_format) {
+ case ExportFormat::PRORES:
+ name = "prores";
+ break;
+ case ExportFormat::H264_AAC:
+ name = "h264-aac";
+ break;
+ case ExportFormat::SUBTITLES_DCP:
+ name = "subtitles-dcp";
+ break;
+ }
+
+ node->add_child("Format")->add_child_text(name);
+ node->add_child("MixdownToStereo")->add_child_text(_mixdown_to_stereo ? "1" : "0");
+ node->add_child("SplitReels")->add_child_text(_split_reels ? "1" : "0");
+ node->add_child("SplitStreams")->add_child_text(_split_streams ? "1" : "0");
+ node->add_child("X264CRF")->add_child_text(dcp::raw_convert<string>(_x264_crf));
+}
+
+
+void
+ExportConfig::set_format(ExportFormat format)
+{
+ _config->maybe_set(_format, format);
+}
+
+
+void
+ExportConfig::set_mixdown_to_stereo(bool mixdown)
+{
+ _config->maybe_set(_mixdown_to_stereo, mixdown);
+}
+
+
+void
+ExportConfig::set_split_reels(bool split)
+{
+ _config->maybe_set(_split_reels, split);
+}
+
+
+void
+ExportConfig::set_split_streams(bool split)
+{
+ _config->maybe_set(_split_streams, split);
+}
+
+
+void
+ExportConfig::set_x264_crf(int crf)
+{
+ _config->maybe_set(_x264_crf, crf);
+}
+
diff --git a/src/lib/export_config.h b/src/lib/export_config.h
new file mode 100644
index 000000000..2b0ddfda2
--- /dev/null
+++ b/src/lib/export_config.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_EXPORT_CONFIG_H
+#define DCPOMATIC_EXPORT_CONFIG_H
+
+
+#include "types.h"
+#include <libcxml/cxml.h>
+
+
+class Config;
+
+
+class ExportConfig
+{
+public:
+ ExportConfig(Config* parent);
+
+ void set_defaults();
+ void read(cxml::ConstNodePtr node);
+ void write(xmlpp::Element* node) const;
+
+ ExportFormat format() const {
+ return _format;
+ }
+
+ bool mixdown_to_stereo() const {
+ return _mixdown_to_stereo;
+ }
+
+ bool split_reels() const {
+ return _split_reels;
+ }
+
+ bool split_streams() const {
+ return _split_streams;
+ }
+
+ int x264_crf() const {
+ return _x264_crf;
+ }
+
+ void set_format(ExportFormat format);
+ void set_mixdown_to_stereo(bool mixdown);
+ void set_split_reels(bool split);
+ void set_split_streams(bool split);
+ void set_x264_crf(int crf);
+
+private:
+ Config* _config;
+ ExportFormat _format;
+ bool _mixdown_to_stereo;
+ bool _split_reels;
+ bool _split_streams;
+ int _x264_crf;
+};
+
+
+#endif
+
diff --git a/src/lib/wscript b/src/lib/wscript
index 7400c5bf1..f4e478219 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -95,6 +95,7 @@ sources = """
examine_content_job.cc
examine_ffmpeg_subtitles_job.cc
exceptions.cc
+ export_config.cc
file_group.cc
file_log.cc
filter_graph.cc
diff --git a/src/wx/export_video_file_dialog.cc b/src/wx/export_video_file_dialog.cc
index 54bdbdf03..2dc452622 100644
--- a/src/wx/export_video_file_dialog.cc
+++ b/src/wx/export_video_file_dialog.cc
@@ -23,6 +23,7 @@
#include "export_video_file_dialog.h"
#include "file_picker_ctrl.h"
#include "wx_util.h"
+#include "lib/config.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/filepicker.h>
@@ -61,6 +62,8 @@ ExportVideoFileDialog::ExportVideoFileDialog (wxWindow* parent, string name)
: TableDialog (parent, _("Export video file"), 2, 1, true)
, _initial_name (name)
{
+ auto& config = Config::instance()->export_config();
+
add (_("Format"), true);
_format = new wxChoice (this, wxID_ANY);
add (_format);
@@ -74,7 +77,7 @@ ExportVideoFileDialog::ExportVideoFileDialog (wxWindow* parent, string name)
_split_streams = new CheckBox (this, _("Write each audio channel to its own stream"));
add (_split_streams, false);
_x264_crf_label[0] = add (_("Quality"), true);
- _x264_crf = new wxSlider (this, wxID_ANY, 23, 0, 51, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
+ _x264_crf = new wxSlider (this, wxID_ANY, config.x264_crf(), 0, 51, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
add (_x264_crf, false);
add_spacer ();
_x264_crf_label[1] = add (_("0 is best, 51 is worst"), false);
@@ -96,33 +99,79 @@ ExportVideoFileDialog::ExportVideoFileDialog (wxWindow* parent, string name)
for (int i = 0; i < FORMATS; ++i) {
_format->Append (format_names[i]);
}
- _format->SetSelection (0);
+ for (int i = 0; i < FORMATS; ++i) {
+ if (config.format() == formats[i]) {
+ _format->SetSelection(i);
+ }
+ }
+
+ _mixdown->SetValue(config.mixdown_to_stereo());
+ _split_reels->SetValue(config.split_reels());
+ _split_streams->SetValue(config.split_streams());
_x264_crf->Enable (false);
for (int i = 0; i < 2; ++i) {
_x264_crf_label[i]->Enable (false);
}
+ _mixdown->Bind (wxEVT_CHECKBOX, bind(&ExportVideoFileDialog::mixdown_changed, this));
+ _split_reels->Bind (wxEVT_CHECKBOX, bind(&ExportVideoFileDialog::split_reels_changed, this));
+ _split_streams->Bind (wxEVT_CHECKBOX, bind(&ExportVideoFileDialog::split_streams_changed, this));
+ _x264_crf->Bind (wxEVT_SLIDER, bind(&ExportVideoFileDialog::x264_crf_changed, this));
_format->Bind (wxEVT_CHOICE, bind (&ExportVideoFileDialog::format_changed, this));
_file->Bind (wxEVT_FILEPICKER_CHANGED, bind (&ExportVideoFileDialog::file_changed, this));
+ format_changed ();
+
layout ();
auto ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
ok->Enable (false);
}
+
+void
+ExportVideoFileDialog::mixdown_changed()
+{
+ Config::instance()->export_config().set_mixdown_to_stereo(_mixdown->GetValue());
+}
+
+
+void
+ExportVideoFileDialog::split_reels_changed()
+{
+ Config::instance()->export_config().set_split_reels(_split_reels->GetValue());
+}
+
+
+void
+ExportVideoFileDialog::split_streams_changed()
+{
+ Config::instance()->export_config().set_split_streams(_split_streams->GetValue());
+}
+
+
+void
+ExportVideoFileDialog::x264_crf_changed()
+{
+ Config::instance()->export_config().set_x264_crf(_x264_crf->GetValue());
+}
+
+
void
ExportVideoFileDialog::format_changed ()
{
- DCPOMATIC_ASSERT (_format->GetSelection() >= 0 && _format->GetSelection() < FORMATS);
- _file->SetWildcard (format_filters[_format->GetSelection()]);
+ auto const selection = _format->GetSelection();
+ DCPOMATIC_ASSERT (selection >= 0 && selection < FORMATS);
+ _file->SetWildcard (format_filters[selection]);
_file->SetPath (_initial_name);
- _x264_crf->Enable (_format->GetSelection() == 1);
+ _x264_crf->Enable (selection == 1);
for (int i = 0; i < 2; ++i) {
- _x264_crf_label[i]->Enable (_format->GetSelection() == 1);
+ _x264_crf_label[i]->Enable (selection == 1);
}
- _mixdown->Enable (_format->GetSelection() != 2);
+ _mixdown->Enable (selection != 2);
+
+ Config::instance()->export_config().set_format(formats[selection]);
}
boost::filesystem::path
diff --git a/src/wx/export_video_file_dialog.h b/src/wx/export_video_file_dialog.h
index 578585362..0b60166c4 100644
--- a/src/wx/export_video_file_dialog.h
+++ b/src/wx/export_video_file_dialog.h
@@ -45,6 +45,10 @@ public:
private:
void format_changed ();
+ void mixdown_changed ();
+ void split_reels_changed ();
+ void split_streams_changed ();
+ void x264_crf_changed ();
void file_changed ();
std::string _initial_name;
diff --git a/test/data b/test/data
-Subproject 6e7c48f621574698db4dcf8021ab137c1f7eee2
+Subproject a89a381e341c161ea636c1018a8f5768b629d87