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 --- include/Config.hpp | 1 + include/gui/SettingsPage.hpp | 7 ++++-- src/Config.cpp | 3 +++ src/Overlay.cpp | 11 ++++++++++ src/gui/SettingsPage.cpp | 51 ++++++++++++++++++++++++++++++++++---------- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/include/Config.hpp b/include/Config.hpp index 549696e..0d2c822 100644 --- a/include/Config.hpp +++ b/include/Config.hpp @@ -17,6 +17,7 @@ namespace gsr { int32_t record_area_width = 0; int32_t record_area_height = 0; int32_t fps = 60; + int32_t video_bitrate = 5000; bool merge_audio_tracks = true; std::vector audio_tracks; std::string color_range = "limited"; diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp index e9102da..4f5a7c9 100644 --- a/include/gui/SettingsPage.hpp +++ b/include/gui/SettingsPage.hpp @@ -49,8 +49,9 @@ namespace gsr { std::unique_ptr create_audio_track_section(); std::unique_ptr create_merge_audio_tracks_checkbox(); std::unique_ptr create_audio_device_section(); - std::unique_ptr create_video_quality_box(); - std::unique_ptr create_video_quality(); + std::unique_ptr create_video_quality_box(); + std::unique_ptr create_video_bitrate_entry(); + std::unique_ptr create_video_bitrate(); std::unique_ptr create_color_range_box(); std::unique_ptr create_color_range(); std::unique_ptr create_video_quality_section(); @@ -115,6 +116,8 @@ namespace gsr { Entry *area_width_entry_ptr = nullptr; Entry *area_height_entry_ptr = nullptr; Entry *framerate_entry_ptr = nullptr; + Entry *video_bitrate_entry_ptr = nullptr; + List *video_bitrate_list_ptr = nullptr; List *audio_devices_list_ptr = nullptr; CheckBox *merge_audio_tracks_checkbox_ptr = nullptr; ComboBox *color_range_box_ptr = nullptr; 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