summaryrefslogtreecommitdiff
path: root/src/lib/create_cli.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/create_cli.cc')
-rw-r--r--src/lib/create_cli.cc75
1 files changed, 54 insertions, 21 deletions
diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc
index 51518ae82..3ef61fe11 100644
--- a/src/lib/create_cli.cc
+++ b/src/lib/create_cli.cc
@@ -20,7 +20,6 @@
#include "audio_content.h"
-#include "compose.hpp"
#include "config.h"
#include "content_factory.h"
#include "create_cli.h"
@@ -61,8 +60,8 @@ help()
DCPOMATIC_ASSERT(colour_conversions.length() > 2);
colour_conversions = colour_conversions.substr(0, colour_conversions.length() - 2);
- return string("\nSyntax: %1 [OPTION] <CONTENT> [OPTION] [<CONTENT> ...]\n") +
- variant::insert_dcpomatic(" -v, --version show %1 version\n") +
+ return string("\nSyntax: {} [OPTION] <CONTENT> [OPTION] [<CONTENT> ...]\n") +
+ variant::insert_dcpomatic(" -v, --version show {} version\n") +
" -h, --help show this help\n"
" -n, --name <name> film name\n"
" -t, --template <name> template name\n"
@@ -86,6 +85,8 @@ help()
" --left-eye next piece of content is for the left eye\n"
" --right-eye next piece of content is for the right eye\n"
" --auto-crop next piece of content should be auto-cropped\n"
+ " --fill-crop next piece of content should be cropped to fit the container\n"
+ " (e.g. to crop the letterboxing from a scope-in-flat image)\n"
" --colourspace next piece of content is in the given colourspace: " + colour_conversions + "\n"
" --colorspace same as --colourspace\n"
" --channel <channel> next piece of content should be mapped to audio channel L, R, C, Lfe, Ls, Rs, BsL, BsR, HI, VI\n"
@@ -107,7 +108,7 @@ argument_option (int& n, int argc, char* argv[], string short_name, string long_
}
if ((n + 1) >= argc) {
- **error = String::compose("%1: option %2 requires an argument", argv[0], long_name);
+ **error = fmt::format("{}: option {} requires an argument", argv[0], long_name);
return;
}
@@ -126,7 +127,7 @@ argument_option(int& n, int argc, char* argv[], string short_name, string long_n
}
if ((n + 1) >= argc) {
- **error = String::compose("%1: option %2 requires an argument", argv[0], long_name);
+ **error = fmt::format("{}: option {} requires an argument", argv[0], long_name);
return;
}
@@ -155,14 +156,14 @@ argument_option(
}
if ((n + 1) >= argc) {
- **error = String::compose("%1: option %2 requires an argument", argv[0], long_name);
+ **error = fmt::format("{}: option {} requires an argument", argv[0], long_name);
return;
}
auto const arg = argv[++n];
auto const value = convert(arg);
if (!value) {
- *error = String::compose("%1: %2 is not valid for %3", argv[0], arg, long_name);
+ *error = fmt::format("{}: {} is not valid for {}", argv[0], arg, long_name);
*claimed = true;
return;
}
@@ -185,6 +186,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
optional<string> next_colour_conversion;
auto next_frame_type = VideoFrameType::TWO_D;
auto next_auto_crop = false;
+ auto next_fill_crop = false;
optional<dcp::Channel> channel;
optional<float> gain;
optional<float> fade_in;
@@ -203,7 +205,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
} else if (a == "-h" || a == "--help") {
error = "Create a film directory (ready for making a DCP) or metadata file from some content files.\n"
"A film directory will be created if -o or --output is specified, otherwise a metadata file\n"
- "will be written to stdout.\n" + String::compose(help(), argv[0]);
+ "will be written to stdout.\n" + fmt::format(help(), argv[0]);
return;
}
@@ -226,6 +228,9 @@ CreateCLI::CreateCLI(int argc, char* argv[])
} else if (a == "--auto-crop") {
next_auto_crop = true;
claimed = true;
+ } else if (a == "--fill-crop") {
+ next_fill_crop = true;
+ claimed = true;
} else if (a == "--twok") {
_twok = true;
claimed = true;
@@ -312,7 +317,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
if (!claimed) {
if (a.length() > 2 && a.substr(0, 2) == "--") {
- error = String::compose("%1: unrecognised option '%2'", argv[0], a) + String::compose(help(), argv[0]);
+ error = fmt::format("{}: unrecognised option '{}'", argv[0], a) + fmt::format(help(), argv[0]);
return;
} else {
if (next_colour_conversion) {
@@ -332,6 +337,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
c.path = a;
c.frame_type = next_frame_type;
c.auto_crop = next_auto_crop;
+ c.fill_crop = next_fill_crop;
c.colour_conversion = next_colour_conversion;
c.channel = channel;
c.gain = gain;
@@ -342,6 +348,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
content.push_back(c);
next_frame_type = VideoFrameType::TWO_D;
next_auto_crop = false;
+ next_fill_crop = false;
next_colour_conversion = {};
channel = {};
gain = {};
@@ -368,7 +375,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
if (dcp_content_type_string) {
_dcp_content_type = DCPContentType::from_isdcf_name(*dcp_content_type_string);
if (!_dcp_content_type) {
- error = String::compose("%1: unrecognised DCP content type '%2'", argv[0], *dcp_content_type_string);
+ error = fmt::format("{}: unrecognised DCP content type '{}'", argv[0], *dcp_content_type_string);
return;
}
}
@@ -376,7 +383,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
if (!container_ratio_string.empty()) {
_container_ratio = Ratio::from_id_if_exists(container_ratio_string);
if (!_container_ratio) {
- error = String::compose("%1: unrecognised container ratio %2", argv[0], container_ratio_string);
+ error = fmt::format("{}: unrecognised container ratio {}", argv[0], container_ratio_string);
return;
}
}
@@ -387,21 +394,21 @@ CreateCLI::CreateCLI(int argc, char* argv[])
} else if (*standard_string == "SMPTE") {
_standard = dcp::Standard::SMPTE;
} else {
- error = String::compose("%1: standard must be SMPTE or interop", argv[0]);
+ error = fmt::format("{}: standard must be SMPTE or interop", argv[0]);
return;
}
}
if (_twod && _threed) {
- error = String::compose("%1: specify one of --twod or --threed, not both", argv[0]);
+ error = fmt::format("{}: specify one of --twod or --threed, not both", argv[0]);
}
if (_no_encrypt && _encrypt) {
- error = String::compose("%1: specify one of --no-encrypt or --encrypt, not both", argv[0]);
+ error = fmt::format("{}: specify one of --no-encrypt or --encrypt, not both", argv[0]);
}
if (content.empty()) {
- error = String::compose("%1: no content specified", argv[0]);
+ error = fmt::format("{}: no content specified", argv[0]);
return;
}
@@ -410,7 +417,7 @@ CreateCLI::CreateCLI(int argc, char* argv[])
}
if (_video_bit_rate && (*_video_bit_rate < 10000000 || *_video_bit_rate > Config::instance()->maximum_video_bit_rate(VideoEncoding::JPEG2000))) {
- error = String::compose("%1: video-bit-rate must be between 10 and %2 Mbit/s", argv[0], (Config::instance()->maximum_video_bit_rate(VideoEncoding::JPEG2000) / 1000000));
+ error = fmt::format("{}: video-bit-rate must be between 10 and {} Mbit/s", argv[0], (Config::instance()->maximum_video_bit_rate(VideoEncoding::JPEG2000) / 1000000));
return;
}
@@ -474,9 +481,13 @@ CreateCLI::make_film(function<void (string)> error) const
}
film->set_use_isdcf_name(!_no_use_isdcf_name);
if (_no_encrypt) {
- film->set_encrypted(false);
+ film->set_encrypt_picture(false);
+ film->set_encrypt_sound(false);
+ film->set_encrypt_text(false);
} else if (_encrypt) {
- film->set_encrypted(true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
+ film->set_encrypt_text(true);
}
if (_twod) {
film->set_three_d(false);
@@ -515,9 +526,7 @@ CreateCLI::make_film(function<void (string)> error) const
film_content_list = content_factory(can);
}
- for (auto film_content: film_content_list) {
- film->examine_and_add_content(film_content);
- }
+ film->examine_and_add_content(film_content_list);
while (jm->work_to_do()) {
dcpomatic_sleep_seconds(1);
@@ -554,6 +563,30 @@ CreateCLI::make_film(function<void (string)> error) const
video->set_crop(crop);
}
+ if (cli_content.fill_crop && video->size()) {
+ auto const source_ratio = video->size()->ratio();
+ Crop crop;
+ if (source_ratio < film->container().ratio()) {
+ /* Part to extract is wider than the source */
+ auto const height = video->size()->width / film->container().ratio();
+ crop.top = crop.bottom = (video->size()->height - height) / 2;
+ } else {
+ /* Container is wider than the source */
+ auto const width = video->size()->height * film->container().ratio();
+ crop.left = crop.right = (video->size()->width - width) / 2;
+ }
+
+ error(fmt::format(
+ "Cropped {} to {} left, {} right, {} top and {} bottom",
+ film_content->path(0).string(),
+ crop.left,
+ crop.right,
+ crop.top,
+ crop.bottom
+ ));
+
+ video->set_crop(crop);
+ }
if (cli_content.colour_conversion) {
video->set_colour_conversion(PresetColourConversion::from_id(*cli_content.colour_conversion).conversion);
}