From 9d76b0861eb0249194e96b663fbeca60cd5bfeb0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 9 Oct 2024 19:08:55 +0200 Subject: Add constant bitrate option --- src/Config.cpp | 3 +++ src/Overlay.cpp | 11 +++++++++++ src/gui/SettingsPage.cpp | 51 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 54 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Config.cpp b/src/Config.cpp index 8f28c89..2f99625 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -30,6 +30,7 @@ namespace gsr { {"streaming.record_options.record_area_width", &config.streaming_config.record_options.record_area_width}, {"streaming.record_options.record_area_height", &config.streaming_config.record_options.record_area_height}, {"streaming.record_options.fps", &config.streaming_config.record_options.fps}, + {"streaming.record_options.video_bitrate", &config.streaming_config.record_options.video_bitrate}, {"streaming.record_options.merge_audio_tracks", &config.streaming_config.record_options.merge_audio_tracks}, {"streaming.record_options.audio_track", &config.streaming_config.record_options.audio_tracks}, {"streaming.record_options.color_range", &config.streaming_config.record_options.color_range}, @@ -54,6 +55,7 @@ namespace gsr { {"record.record_options.record_area_width", &config.record_config.record_options.record_area_width}, {"record.record_options.record_area_height", &config.record_config.record_options.record_area_height}, {"record.record_options.fps", &config.record_config.record_options.fps}, + {"record.record_options.video_bitrate", &config.record_config.record_options.video_bitrate}, {"record.record_options.merge_audio_tracks", &config.record_config.record_options.merge_audio_tracks}, {"record.record_options.audio_track", &config.record_config.record_options.audio_tracks}, {"record.record_options.color_range", &config.record_config.record_options.color_range}, @@ -76,6 +78,7 @@ namespace gsr { {"replay.record_options.record_area_width", &config.replay_config.record_options.record_area_width}, {"replay.record_options.record_area_height", &config.replay_config.record_options.record_area_height}, {"replay.record_options.fps", &config.replay_config.record_options.fps}, + {"replay.record_options.video_bitrate", &config.replay_config.record_options.video_bitrate}, {"replay.record_options.merge_audio_tracks", &config.replay_config.record_options.merge_audio_tracks}, {"replay.record_options.audio_track", &config.replay_config.record_options.audio_tracks}, {"replay.record_options.color_range", &config.replay_config.record_options.color_range}, diff --git a/src/Overlay.cpp b/src/Overlay.cpp index dcd18cf..34988f1 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -717,6 +717,7 @@ namespace gsr { // TODO: Validate input, fallback to valid values const std::string fps = std::to_string(config->record_config.record_options.fps); + const std::string video_bitrate = std::to_string(config->record_config.record_options.video_bitrate); const std::string output_file = config->record_config.save_directory + "/Video_" + get_date_str() + "." + container_to_file_extension(config->record_config.container.c_str()); const std::string audio_tracks_merged = merge_audio_tracks(config->record_config.record_options.audio_tracks); const std::string framerate_mode = config->record_config.record_options.framerate_mode == "auto" ? "vfr" : config->record_config.record_options.framerate_mode; @@ -736,6 +737,16 @@ namespace gsr { "-o", output_file.c_str() }; + if(config->record_config.record_options.video_quality == "custom") { + args.push_back("-bm"); + args.push_back("cbr"); + args.push_back("-q"); + args.push_back(video_bitrate.c_str()); + } else { + args.push_back("-q"); + args.push_back(config->record_config.record_options.video_quality.c_str()); + } + if(config->record_config.record_options.record_area_option == "window" || config->record_config.record_options.record_area_option == "focused") { args.push_back("-s"); args.push_back(region); diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index 751102c..2e7035b 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -190,22 +190,36 @@ namespace gsr { return std::make_unique("Audio", std::move(audio_device_section_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)); } - std::unique_ptr SettingsPage::create_video_quality_box() { + std::unique_ptr SettingsPage::create_video_quality_box() { + auto list = std::make_unique(List::Orientation::VERTICAL); + list->add_widget(std::make_unique