Skip to content

Commit

Permalink
lock aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
TobyAdd committed Oct 19, 2024
1 parent afd9132 commit 7df9e30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 4.7.7
- fixed recorder aspect ratio mismatch
- lock aspect ratio for recording resoluion input (16:9)

# 4.7.6
- fixed replay system (again)
Expand Down
3 changes: 3 additions & 0 deletions src/recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Recorder {
int width = 1280;
int height = 720;
int fps = 60;

bool lock_aspect_ratio = true;

std::string bitrate = "0";
std::string codec = "libx264";
std::string extra_args = "-pix_fmt yuv420p -preset ultrafast";
Expand Down
14 changes: 12 additions & 2 deletions src/replayEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,20 @@ void ReplayEngine::render() {
ImGui::Separator();

ImGui::PushItemWidth(45.f * gui::scale);
ImGui::InputInt("##width", &recorder.width, 0);
if (ImGui::InputInt("##width", &recorder.width, 0) && recorder.lock_aspect_ratio) {
float aspect_ratio = 16.0f / 9.0f;
recorder.height = static_cast<int>(recorder.width / aspect_ratio);
}
ImGui::SameLine(0, 5);

ImGui::Text("x");
ImGui::SameLine(0, 5);

ImGui::PushItemWidth(45.f * gui::scale);
ImGui::InputInt("##height", &recorder.height, 0);
if (ImGui::InputInt("##height", &recorder.height, 0) && recorder.lock_aspect_ratio) {
float aspect_ratio = 16.0f / 9.0f;
recorder.width = static_cast<int>(recorder.height * aspect_ratio);
}
ImGui::SameLine(0, 5);

ImGui::Text("@");
Expand All @@ -554,6 +560,10 @@ void ReplayEngine::render() {
ImGui::PushItemWidth(35.f * gui::scale);
ImGui::InputInt("##fps", &recorder.fps, 0);

ImGui::SameLine(0, 5);

ImGui::Checkbox("Lock Aspect Ratio (16:9)", &recorder.lock_aspect_ratio, gui::scale);

ImGui::Spacing();

ImGui::Text("Encoding Settings");
Expand Down

0 comments on commit 7df9e30

Please sign in to comment.