From 115aa573e18f56a18a04a6e4c0c5f69fc335f8c9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 15 Jun 2025 20:58:01 +0200 Subject: Add --fade-{in,out} options to create CLI (#2613). --- src/lib/create_cli.cc | 25 ++++++++++++++++++++++++- src/lib/create_cli.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index af63f94fd..5f3d672bd 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -90,6 +90,8 @@ help() " --colorspace same as --colourspace\n" " --channel next piece of content should be mapped to audio channel L, R, C, Lfe, Ls, Rs, BsL, BsR, HI, VI\n" " --gain next piece of content should have the given audio gain (in dB)\n" + " --fade-in next piece of content should have the given fade-in (in seconds)\n" + " --fade-out next piece of content should have the given fade-out (in seconds)\n" " --cpl CPL ID to use from the next piece of content (which is a DCP)\n" " --kdm KDM for next piece of content\n"; } @@ -185,6 +187,8 @@ CreateCLI::CreateCLI(int argc, char* argv[]) auto next_auto_crop = false; optional channel; optional gain; + optional fade_in; + optional fade_out; optional kdm; optional cpl; @@ -298,6 +302,8 @@ CreateCLI::CreateCLI(int argc, char* argv[]) argument_option(i, argc, argv, "", "--channel", &claimed, &error, &channel, convert_channel); argument_option(i, argc, argv, "", "--gain", &claimed, &error, &gain); + argument_option(i, argc, argv, "", "--fade-in", &claimed, &error, &fade_in); + argument_option(i, argc, argv, "", "--fade-out", &claimed, &error, &fade_out); argument_option(i, argc, argv, "", "--kdm", &claimed, &error, &kdm, string_to_path); /* It shouldn't be necessary to use this string_to_string here, but using the other argument_option() * causes an odd compile error on Ubuntu 18.04. @@ -329,6 +335,8 @@ CreateCLI::CreateCLI(int argc, char* argv[]) c.colour_conversion = next_colour_conversion; c.channel = channel; c.gain = gain; + c.fade_in = fade_in; + c.fade_out = fade_out; c.kdm = kdm; c.cpl = cpl; content.push_back(c); @@ -337,6 +345,8 @@ CreateCLI::CreateCLI(int argc, char* argv[]) next_colour_conversion = {}; channel = {}; gain = {}; + fade_in = {}; + fade_out = {}; } } @@ -517,6 +527,7 @@ CreateCLI::make_film(function error) const for (auto film_content: film_content_list) { if (auto video = film_content->video) { + auto const video_frame_rate = film_content->video_frame_rate().get_value_or(24); video->set_frame_type(cli_content.frame_type); if (cli_content.auto_crop) { auto crop = guess_crop_by_brightness( @@ -527,7 +538,7 @@ CreateCLI::make_film(function error) const dcpomatic::ContentTime::from_seconds(1), dcpomatic::ContentTime::from_frames( video->length(), - film_content->video_frame_rate().get_value_or(24) + video_frame_rate ) ) ); @@ -546,6 +557,12 @@ CreateCLI::make_film(function error) const if (cli_content.colour_conversion) { video->set_colour_conversion(PresetColourConversion::from_id(*cli_content.colour_conversion).conversion); } + if (cli_content.fade_in) { + video->set_fade_in(dcpomatic::ContentTime::from_seconds(*cli_content.fade_in).frames_round(video_frame_rate)); + } + if (cli_content.fade_out) { + video->set_fade_out(dcpomatic::ContentTime::from_seconds(*cli_content.fade_out).frames_round(video_frame_rate)); + } } if (auto audio = film_content->audio) { if (cli_content.channel) { @@ -560,6 +577,12 @@ CreateCLI::make_film(function error) const if (cli_content.gain) { audio->set_gain(*cli_content.gain); } + if (cli_content.fade_in) { + audio->set_fade_in(dcpomatic::ContentTime::from_seconds(*cli_content.fade_in)); + } + if (cli_content.fade_out) { + audio->set_fade_out(dcpomatic::ContentTime::from_seconds(*cli_content.fade_out)); + } } } } diff --git a/src/lib/create_cli.h b/src/lib/create_cli.h index 39024d786..4767b1aa7 100644 --- a/src/lib/create_cli.h +++ b/src/lib/create_cli.h @@ -45,6 +45,8 @@ public: boost::optional colour_conversion; boost::optional channel; boost::optional gain; + boost::optional fade_in; + boost::optional fade_out; boost::optional kdm; boost::optional cpl; }; -- cgit v1.2.3