diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-19 21:11:03 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-19 21:11:17 +0100 |
| commit | 4ddd6052b00a07583fda682730dde3c3d1206d1b (patch) | |
| tree | 6dc16f1ed72016c4f0fc95c25826ff3f1962745b | |
| parent | 0692355b1e4d29b1ccb6e4b83554ffec342a74ad (diff) | |
Add --auto-crop-threshold option to create CLI.
| -rw-r--r-- | doc/manual/dcpomatic_create.xml | 1 | ||||
| -rw-r--r-- | src/lib/create_cli.cc | 4 | ||||
| -rw-r--r-- | src/lib/create_cli.h | 1 | ||||
| -rw-r--r-- | test/create_cli_test.cc | 7 |
4 files changed, 12 insertions, 1 deletions
diff --git a/doc/manual/dcpomatic_create.xml b/doc/manual/dcpomatic_create.xml index 516b806ff..9e029992d 100644 --- a/doc/manual/dcpomatic_create.xml +++ b/doc/manual/dcpomatic_create.xml @@ -10,6 +10,7 @@ <listitem><code>-f</code>, <code>--dcp-frame-rate <rate></code> — set DCP video frame rate (otherwise guessed from content)</listitem> <listitem><code>--container-ratio <ratio></code> — 119, 133, 137, 138, 166, 178, 185 or 239</listitem> <listitem><code>-s</code>, <code>--still-length <n></code> — number of seconds that still content should last</listitem> +<listitem><code>--auto-crop-threshold <n></code> — threshold to use for 'black' when auto-cropping</listitem> <listitem><code>--standard <standard></code> — SMPTE or interop (default SMPTE)</listitem> <listitem><code>--no-use-isdcf-name</code> — do not use an ISDCF name; use the specified name unmodified</listitem> <listitem><code>--config <dir></code> — directory containing config.xml and cinemas.sqlite3</listitem> diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index 96a889bc4..6ccd2e20f 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -62,6 +62,7 @@ string CreateCLI::_help = " -f, --dcp-frame-rate <rate> set DCP video frame rate (otherwise guessed from content)\n" " --container-ratio <ratio> 119, 133, 137, 138, 166, 178, 185 or 239\n" " -s, --still-length <n> number of seconds that still content should last\n" + " --auto-crop-threshold <n> threshold to use for 'black' when auto-cropping\n" " --standard <standard> SMPTE or interop (default SMPTE)\n" " --no-use-isdcf-name do not use an ISDCF name; use the specified name unmodified\n" " --config <dir> directory containing config.xml and cinemas.sqlite3\n" @@ -242,6 +243,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) argument_option(i, argc, argv, "-f", "--dcp-frame-rate", &claimed, &error, &dcp_frame_rate_int); argument_option(i, argc, argv, "", "--container-ratio", &claimed, &error, &container_ratio_string); argument_option(i, argc, argv, "-s", "--still-length", &claimed, &error, &still_length, string_to_nonzero_int); + argument_option(i, argc, argv, "", "--auto-crop-threshold", &claimed, &error, &auto_crop_threshold, string_to_int); /* See comment below about --cpl */ argument_option(i, argc, argv, "", "--standard", &claimed, &error, &standard_string, string_to_string); argument_option(i, argc, argv, "", "--config", &claimed, &error, &config_dir, string_to_path); @@ -489,7 +491,7 @@ CreateCLI::make_film(function<void (string)> error) const auto crop = guess_crop_by_brightness( film, film_content, - Config::instance()->auto_crop_threshold(), + auto_crop_threshold.get_value_or(Config::instance()->auto_crop_threshold()), std::min( dcpomatic::ContentTime::from_seconds(1), dcpomatic::ContentTime::from_frames( diff --git a/src/lib/create_cli.h b/src/lib/create_cli.h index 875fe10c1..108466afd 100644 --- a/src/lib/create_cli.h +++ b/src/lib/create_cli.h @@ -51,6 +51,7 @@ public: bool version; boost::optional<int> dcp_frame_rate; boost::optional<int> still_length; + boost::optional<int> auto_crop_threshold; boost::optional<boost::filesystem::path> config_dir; boost::optional<boost::filesystem::path> output_dir; boost::optional<std::string> error; diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc index 6499ef160..5831e6b6f 100644 --- a/test/create_cli_test.cc +++ b/test/create_cli_test.cc @@ -201,6 +201,13 @@ BOOST_AUTO_TEST_CASE (create_cli_test) BOOST_CHECK(!cc.content[1].auto_crop); BOOST_CHECK(cc.content[2].auto_crop); + cc = run("dcpomatic2_create --auto-crop-threshold 42 --auto-crop foo.mp4 bar.mp4 --auto-crop baz.mp4"); + BOOST_REQUIRE_EQUAL(cc.content.size(), 3U); + BOOST_CHECK(cc.content[0].auto_crop); + BOOST_CHECK(!cc.content[1].auto_crop); + BOOST_CHECK(cc.content[2].auto_crop); + BOOST_CHECK_EQUAL(cc.auto_crop_threshold.get_value_or(0), 42); + auto pillarbox = TestPaths::private_data() / "pillarbox.png"; cc = run("dcpomatic2_create --auto-crop " + pillarbox.string()); auto film = cc.make_film(error); |
