mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Add option to change video resolution
This commit is contained in:
@@ -16,9 +16,12 @@ namespace gsr {
|
||||
std::string record_area_option = "screen";
|
||||
int32_t record_area_width = 0;
|
||||
int32_t record_area_height = 0;
|
||||
int32_t video_width = 0;
|
||||
int32_t video_height = 0;
|
||||
int32_t fps = 60;
|
||||
int32_t video_bitrate = 5000;
|
||||
bool merge_audio_tracks = true;
|
||||
bool change_video_resolution = false;
|
||||
std::vector<std::string> audio_tracks;
|
||||
std::string color_range = "limited";
|
||||
std::string video_quality = "very_high";
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <mglpp/graphics/Text.hpp>
|
||||
#include <mglpp/graphics/Sprite.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace gsr {
|
||||
class CheckBox : public Widget {
|
||||
public:
|
||||
@@ -20,6 +22,8 @@ namespace gsr {
|
||||
|
||||
void set_checked(bool checked, bool animated = false);
|
||||
bool is_checked() const;
|
||||
|
||||
std::function<void(bool checked)> on_changed;
|
||||
private:
|
||||
void apply_animation();
|
||||
mgl::vec2f get_checkbox_size();
|
||||
|
||||
@@ -39,8 +39,13 @@ namespace gsr {
|
||||
std::unique_ptr<Entry> create_area_height_entry();
|
||||
std::unique_ptr<List> create_area_size();
|
||||
std::unique_ptr<List> create_area_size_section();
|
||||
std::unique_ptr<Entry> create_video_width_entry();
|
||||
std::unique_ptr<Entry> create_video_height_entry();
|
||||
std::unique_ptr<List> create_video_resolution();
|
||||
std::unique_ptr<List> create_video_resolution_section();
|
||||
std::unique_ptr<CheckBox> create_restore_portal_session_checkbox();
|
||||
std::unique_ptr<List> create_restore_portal_session_section();
|
||||
std::unique_ptr<Widget> create_change_video_resolution_section();
|
||||
std::unique_ptr<Widget> create_capture_target(const GsrInfo &gsr_info);
|
||||
std::unique_ptr<ComboBox> create_audio_track_selection_checkbox();
|
||||
std::unique_ptr<Button> create_remove_audio_track_button(List *audio_device_list_ptr);
|
||||
@@ -107,6 +112,7 @@ namespace gsr {
|
||||
List *settings_list_ptr = nullptr;
|
||||
List *select_window_list_ptr = nullptr;
|
||||
List *area_size_list_ptr = nullptr;
|
||||
List *video_resolution_list_ptr = nullptr;
|
||||
List *restore_portal_session_list_ptr = nullptr;
|
||||
List *color_range_list_ptr = nullptr;
|
||||
Widget *video_codec_ptr = nullptr;
|
||||
@@ -115,11 +121,14 @@ namespace gsr {
|
||||
ComboBox *record_area_box_ptr = nullptr;
|
||||
Entry *area_width_entry_ptr = nullptr;
|
||||
Entry *area_height_entry_ptr = nullptr;
|
||||
Entry *video_width_entry_ptr = nullptr;
|
||||
Entry *video_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;
|
||||
CheckBox *change_video_resolution_checkbox_ptr = nullptr;
|
||||
ComboBox *color_range_box_ptr = nullptr;
|
||||
ComboBox *video_quality_box_ptr = nullptr;
|
||||
ComboBox *video_codec_box_ptr = nullptr;
|
||||
|
||||
@@ -36,9 +36,12 @@ namespace gsr {
|
||||
{"streaming.record_options.record_area_option", &config.streaming_config.record_options.record_area_option},
|
||||
{"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.video_width", &config.streaming_config.record_options.video_width},
|
||||
{"streaming.record_options.video_height", &config.streaming_config.record_options.video_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.change_video_resolution", &config.streaming_config.record_options.change_video_resolution},
|
||||
{"streaming.record_options.audio_track", &config.streaming_config.record_options.audio_tracks},
|
||||
{"streaming.record_options.color_range", &config.streaming_config.record_options.color_range},
|
||||
{"streaming.record_options.video_quality", &config.streaming_config.record_options.video_quality},
|
||||
@@ -61,9 +64,12 @@ namespace gsr {
|
||||
{"record.record_options.record_area_option", &config.record_config.record_options.record_area_option},
|
||||
{"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.video_width", &config.record_config.record_options.video_width},
|
||||
{"record.record_options.video_height", &config.record_config.record_options.video_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.change_video_resolution", &config.record_config.record_options.change_video_resolution},
|
||||
{"record.record_options.audio_track", &config.record_config.record_options.audio_tracks},
|
||||
{"record.record_options.color_range", &config.record_config.record_options.color_range},
|
||||
{"record.record_options.video_quality", &config.record_config.record_options.video_quality},
|
||||
@@ -84,9 +90,12 @@ namespace gsr {
|
||||
{"replay.record_options.record_area_option", &config.replay_config.record_options.record_area_option},
|
||||
{"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.video_width", &config.replay_config.record_options.video_width},
|
||||
{"replay.record_options.video_height", &config.replay_config.record_options.video_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.change_video_resolution", &config.replay_config.record_options.change_video_resolution},
|
||||
{"replay.record_options.audio_track", &config.replay_config.record_options.audio_tracks},
|
||||
{"replay.record_options.color_range", &config.replay_config.record_options.color_range},
|
||||
{"replay.record_options.video_quality", &config.replay_config.record_options.video_quality},
|
||||
|
||||
@@ -704,9 +704,13 @@ namespace gsr {
|
||||
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;
|
||||
|
||||
char region[64];
|
||||
snprintf(region, sizeof(region), "%dx%d", (int)config->record_config.record_options.record_area_width, (int)config->record_config.record_options.record_area_height);
|
||||
|
||||
if(config->record_config.record_options.record_area_option != "focused" && config->record_config.record_options.change_video_resolution)
|
||||
snprintf(region, sizeof(region), "%dx%d", (int)config->record_config.record_options.video_width, (int)config->record_config.record_options.video_height);
|
||||
|
||||
std::vector<const char*> args = {
|
||||
"gpu-screen-recorder", "-w", config->record_config.record_options.record_area_option.c_str(),
|
||||
"-c", config->record_config.container.c_str(),
|
||||
@@ -729,7 +733,7 @@ namespace gsr {
|
||||
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") {
|
||||
if(config->record_config.record_options.record_area_option == "focused" || config->record_config.record_options.change_video_resolution) {
|
||||
args.push_back("-s");
|
||||
args.push_back(region);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,12 @@ namespace gsr {
|
||||
|
||||
if(event.type == mgl::Event::MouseButtonPressed && event.mouse_button.button == mgl::Mouse::Left) {
|
||||
const bool clicked_inside = mgl::FloatRect(position + offset, get_size()).contains({ (float)event.mouse_button.x, (float)event.mouse_button.y });
|
||||
if(clicked_inside)
|
||||
if(clicked_inside) {
|
||||
checked = !checked;
|
||||
if(on_changed)
|
||||
on_changed(checked);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -105,6 +109,8 @@ namespace gsr {
|
||||
this->checked = checked;
|
||||
if(!animated)
|
||||
toggle_animation_value = checked ? 1.0f : 0.0f;
|
||||
if(on_changed)
|
||||
on_changed(checked);
|
||||
}
|
||||
|
||||
bool CheckBox::is_checked() const {
|
||||
|
||||
@@ -111,6 +111,36 @@ namespace gsr {
|
||||
return area_size_list;
|
||||
}
|
||||
|
||||
std::unique_ptr<Entry> SettingsPage::create_video_width_entry() {
|
||||
auto video_width_entry = std::make_unique<Entry>(&get_theme().body_font, "1920", get_theme().body_font.get_character_size() * 3);
|
||||
video_width_entry->validate_handler = create_entry_validator_integer_in_range(1, 1 << 15);
|
||||
video_width_entry_ptr = video_width_entry.get();
|
||||
return video_width_entry;
|
||||
}
|
||||
|
||||
std::unique_ptr<Entry> SettingsPage::create_video_height_entry() {
|
||||
auto video_height_entry = std::make_unique<Entry>(&get_theme().body_font, "1080", get_theme().body_font.get_character_size() * 3);
|
||||
video_height_entry->validate_handler = create_entry_validator_integer_in_range(1, 1 << 15);
|
||||
video_height_entry_ptr = video_height_entry.get();
|
||||
return video_height_entry;
|
||||
}
|
||||
|
||||
std::unique_ptr<List> SettingsPage::create_video_resolution() {
|
||||
auto area_size_params_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
|
||||
area_size_params_list->add_widget(create_video_width_entry());
|
||||
area_size_params_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "x", get_theme().text_color));
|
||||
area_size_params_list->add_widget(create_video_height_entry());
|
||||
return area_size_params_list;
|
||||
}
|
||||
|
||||
std::unique_ptr<List> SettingsPage::create_video_resolution_section() {
|
||||
auto video_resolution_list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||
video_resolution_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Video resolution:", get_theme().text_color));
|
||||
video_resolution_list->add_widget(create_video_resolution());
|
||||
video_resolution_list_ptr = video_resolution_list.get();
|
||||
return video_resolution_list;
|
||||
}
|
||||
|
||||
std::unique_ptr<CheckBox> SettingsPage::create_restore_portal_session_checkbox() {
|
||||
auto restore_portal_session_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Restore portal session");
|
||||
restore_portal_session_checkbox->set_checked(true);
|
||||
@@ -126,14 +156,25 @@ namespace gsr {
|
||||
return restore_portal_session_list;
|
||||
}
|
||||
|
||||
std::unique_ptr<Widget> SettingsPage::create_change_video_resolution_section() {
|
||||
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Change video resolution");
|
||||
change_video_resolution_checkbox_ptr = checkbox.get();
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
std::unique_ptr<Widget> SettingsPage::create_capture_target(const GsrInfo &gsr_info) {
|
||||
// TODO: List::Alignment::Center causes 1 frame glitch when switching record area but only the first time
|
||||
auto ll = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||
|
||||
auto capture_target_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
|
||||
capture_target_list->add_widget(create_record_area(gsr_info));
|
||||
capture_target_list->add_widget(create_select_window());
|
||||
capture_target_list->add_widget(create_area_size_section());
|
||||
capture_target_list->add_widget(create_video_resolution_section());
|
||||
capture_target_list->add_widget(create_restore_portal_session_section());
|
||||
return std::make_unique<Subsection>("Record area", std::move(capture_target_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
|
||||
|
||||
ll->add_widget(std::move(capture_target_list));
|
||||
ll->add_widget(create_change_video_resolution_section());
|
||||
return std::make_unique<Subsection>("Record area", std::move(ll), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
|
||||
}
|
||||
|
||||
std::unique_ptr<ComboBox> SettingsPage::create_audio_track_selection_checkbox() {
|
||||
@@ -386,9 +427,16 @@ namespace gsr {
|
||||
const bool portal_selected = id == "portal";
|
||||
select_window_list_ptr->set_visible(window_selected);
|
||||
area_size_list_ptr->set_visible(focused_selected);
|
||||
video_resolution_list_ptr->set_visible(!focused_selected && change_video_resolution_checkbox_ptr->is_checked());
|
||||
change_video_resolution_checkbox_ptr->set_visible(!focused_selected);
|
||||
restore_portal_session_list_ptr->set_visible(portal_selected);
|
||||
};
|
||||
|
||||
change_video_resolution_checkbox_ptr->on_changed = [this](bool checked) {
|
||||
const bool focused_selected = record_area_box_ptr->get_selected_id() == "focused";
|
||||
video_resolution_list_ptr->set_visible(!focused_selected && checked);
|
||||
};
|
||||
|
||||
video_quality_box_ptr->on_selection_changed = [this](const std::string &text, const std::string &id) {
|
||||
(void)text;
|
||||
const bool custom_selected = id == "custom";
|
||||
@@ -717,6 +765,7 @@ namespace gsr {
|
||||
void SettingsPage::load_common(RecordOptions &record_options) {
|
||||
record_area_box_ptr->set_selected_item(record_options.record_area_option);
|
||||
merge_audio_tracks_checkbox_ptr->set_checked(record_options.merge_audio_tracks);
|
||||
change_video_resolution_checkbox_ptr->set_checked(record_options.change_video_resolution);
|
||||
|
||||
load_audio_tracks(record_options);
|
||||
color_range_box_ptr->set_selected_item(record_options.color_range);
|
||||
@@ -730,6 +779,18 @@ namespace gsr {
|
||||
record_cursor_checkbox_ptr->set_checked(record_options.record_cursor);
|
||||
restore_portal_session_checkbox_ptr->set_checked(record_options.restore_portal_session);
|
||||
|
||||
if(record_options.record_area_width == 0)
|
||||
record_options.record_area_width = 1920;
|
||||
|
||||
if(record_options.record_area_height == 0)
|
||||
record_options.record_area_height = 1080;
|
||||
|
||||
if(record_options.video_width == 0)
|
||||
record_options.video_width = 1920;
|
||||
|
||||
if(record_options.video_height == 0)
|
||||
record_options.video_height = 1080;
|
||||
|
||||
if(record_options.record_area_width < 32)
|
||||
record_options.record_area_width = 32;
|
||||
area_width_entry_ptr->set_text(std::to_string(record_options.record_area_width));
|
||||
@@ -738,6 +799,14 @@ namespace gsr {
|
||||
record_options.record_area_height = 32;
|
||||
area_height_entry_ptr->set_text(std::to_string(record_options.record_area_height));
|
||||
|
||||
if(record_options.video_width < 32)
|
||||
record_options.video_width = 32;
|
||||
video_width_entry_ptr->set_text(std::to_string(record_options.video_width));
|
||||
|
||||
if(record_options.video_height < 32)
|
||||
record_options.video_height = 32;
|
||||
video_height_entry_ptr->set_text(std::to_string(record_options.video_height));
|
||||
|
||||
if(record_options.fps < 1)
|
||||
record_options.fps = 1;
|
||||
framerate_entry_ptr->set_text(std::to_string(record_options.fps));
|
||||
@@ -793,9 +862,12 @@ namespace gsr {
|
||||
record_options.record_area_option = record_area_box_ptr->get_selected_id();
|
||||
record_options.record_area_width = atoi(area_width_entry_ptr->get_text().c_str());
|
||||
record_options.record_area_height = atoi(area_height_entry_ptr->get_text().c_str());
|
||||
record_options.video_width = atoi(video_width_entry_ptr->get_text().c_str());
|
||||
record_options.video_height = atoi(video_height_entry_ptr->get_text().c_str());
|
||||
record_options.fps = atoi(framerate_entry_ptr->get_text().c_str());
|
||||
record_options.video_bitrate = atoi(video_bitrate_entry_ptr->get_text().c_str());
|
||||
record_options.merge_audio_tracks = merge_audio_tracks_checkbox_ptr->is_checked();
|
||||
record_options.change_video_resolution = change_video_resolution_checkbox_ptr->is_checked();
|
||||
save_audio_tracks(record_options.audio_tracks, audio_devices_list_ptr);
|
||||
record_options.color_range = color_range_box_ptr->get_selected_id();
|
||||
record_options.video_quality = video_quality_box_ptr->get_selected_id();
|
||||
@@ -808,6 +880,18 @@ namespace gsr {
|
||||
record_options.record_cursor = record_cursor_checkbox_ptr->is_checked();
|
||||
record_options.restore_portal_session = restore_portal_session_checkbox_ptr->is_checked();
|
||||
|
||||
if(record_options.record_area_width == 0)
|
||||
record_options.record_area_width = 1920;
|
||||
|
||||
if(record_options.record_area_height == 0)
|
||||
record_options.record_area_height = 1080;
|
||||
|
||||
if(record_options.video_width == 0)
|
||||
record_options.video_width = 1920;
|
||||
|
||||
if(record_options.video_height == 0)
|
||||
record_options.video_height = 1080;
|
||||
|
||||
if(record_options.record_area_width < 32) {
|
||||
record_options.record_area_width = 32;
|
||||
area_width_entry_ptr->set_text("32");
|
||||
@@ -818,6 +902,16 @@ namespace gsr {
|
||||
area_height_entry_ptr->set_text("32");
|
||||
}
|
||||
|
||||
if(record_options.video_width < 32) {
|
||||
record_options.video_width = 32;
|
||||
video_width_entry_ptr->set_text("32");
|
||||
}
|
||||
|
||||
if(record_options.video_height < 32) {
|
||||
record_options.video_height = 32;
|
||||
video_height_entry_ptr->set_text("32");
|
||||
}
|
||||
|
||||
if(record_options.fps < 1) {
|
||||
record_options.fps = 1;
|
||||
framerate_entry_ptr->set_text("1");
|
||||
|
||||
Reference in New Issue
Block a user