Add --auto-crop-threshold option to create CLI.
authorCarl Hetherington <cth@carlh.net>
Wed, 19 Mar 2025 20:11:03 +0000 (21:11 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Mar 2025 20:11:17 +0000 (21:11 +0100)
doc/manual/dcpomatic_create.xml
src/lib/create_cli.cc
src/lib/create_cli.h
test/create_cli_test.cc

index 516b806ffcfc597bcbd5663279eb1f7b472c786c..9e029992ddb27a64559054b4b66559ac3fc35af8 100644 (file)
@@ -10,6 +10,7 @@
 <listitem><code>-f</code>, <code>--dcp-frame-rate &lt;rate&gt;</code> &#8212; set DCP video frame rate (otherwise guessed from content)</listitem>
 <listitem><code>--container-ratio &lt;ratio&gt;</code> &#8212; 119, 133, 137, 138, 166, 178, 185 or 239</listitem>
 <listitem><code>-s</code>, <code>--still-length &lt;n&gt;</code> &#8212; number of seconds that still content should last</listitem>
+<listitem><code>--auto-crop-threshold &lt;n&gt;</code> &#8212; threshold to use for 'black' when auto-cropping</listitem>
 <listitem><code>--standard &lt;standard&gt;</code> &#8212; SMPTE or interop (default SMPTE)</listitem>
 <listitem><code>--no-use-isdcf-name</code> &#8212; do not use an ISDCF name; use the specified name unmodified</listitem>
 <listitem><code>--config &lt;dir&gt;</code> &#8212; directory containing config.xml and cinemas.sqlite3</listitem>
index 96a889bc4f3aa0b9915b7fbe441e3f16860a92ff..6ccd2e20fc8084fe88ed63136e0b52e9e9ec3404 100644 (file)
@@ -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(
index 875fe10c12a76b49da881c4a451dd6e6dd860072..108466afdddfa4dd2470c59ebf0b5573d9bc53fa 100644 (file)
@@ -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;
index 6499ef160a9aeb4802f44dd1aed66e62f05469d8..5831e6b6fa542f9779193791f586cd5daf8369a1 100644 (file)
@@ -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);