From f9e99e57f9c193e70ca4abf5f33aa4f112b13e89 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 4 Apr 2020 14:54:12 +0200 Subject: [PATCH] Add interactive record script --- README.md | 2 +- interactive.sh | 30 ++++++++++++++++++++++++++++++ src/main.cpp | 12 ++++++------ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100755 interactive.sh diff --git a/README.md b/README.md index 91ef064..bcc0516 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ When recording a 4k game, fps drops from 30 to 7 when using OBS Studio, however the fps remains at 30. # Example -`gpu-screen-recorder -w 0x1c00001 -c mp4 -f 60 -a bluez_sink.00_18_09_8A_07_93.a2dp_sink.monitor > test_video.mp4` +Run `interactive.sh` or run `gpu-screen-recorder -w 0x1c00001 -c mp4 -f 60 -a bluez_sink.00_18_09_8A_07_93.a2dp_sink.monitor > test_video.mp4` # Demo [![Click here to watch a demo video on youtube](https://img.youtube.com/vi/n5tm0g01n6A/0.jpg)](https://www.youtube.com/watch?v=n5tm0g01n6A) diff --git a/interactive.sh b/interactive.sh new file mode 100755 index 0000000..54a4d62 --- /dev/null +++ b/interactive.sh @@ -0,0 +1,30 @@ +#!/bin/sh -e + +print_selected_window_id() { + xwininfo | grep 'Window id:' | cut -d' ' -f4 +} + +echo "Select a window to record" +window_id=$(print_selected_window_id) + +echo -n "Enter video fps: " +read fps + +echo "Select audio input:" +selected_audio_input="" +select audio_input in $(pactl list | sed -rn 's/Monitor Source: (.*)/\1/p'); do + if [ "$audio_input" == "" ]; then + echo "Invalid option $REPLY" + else + selected_audio_input="$audio_input" + break + fi +done + +echo -n "Enter output file name: " +read output_file_name + +output_dir=$(dirname "$output_file_name") +mkdir -p "$output_dir" + +sibs build --release && ./sibs-build/linux_x86_64/release/gpu-screen-recorder -w "$window_id" -c mp4 -f "$fps" -a "$selected_audio_input" > "$output_file_name" diff --git a/src/main.cpp b/src/main.cpp index 4d43cd7..5db9d6f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -743,7 +743,7 @@ int main(int argc, char **argv) { double start_time = glfwGetTime(); double frame_timer_start = start_time; double window_resize_timer = start_time; - bool window_resized = true; + bool window_resized = false; int fps_counter = 0; int current_fps = 30; @@ -841,7 +841,7 @@ int main(int argc, char **argv) { window_width = e.xconfigure.width; window_height = e.xconfigure.height; window_resize_timer = glfwGetTime(); - window_resized = false; + window_resized = true; } } @@ -894,13 +894,13 @@ int main(int argc, char **argv) { } const double window_resize_timeout = 1.0; // 1 second - if(!window_resized && time_now - window_resize_timer >= window_resize_timeout) { - window_resized = true; + if(window_resized && time_now - window_resize_timer >= window_resize_timeout) { + window_resized = false; fprintf(stderr, "Resize window!\n"); recreate_window_pixmap(dpy, src_window_id, window_pixmap); // Resolution must be a multiple of two - video_stream->codec->width = window_pixmap.texture_width & ~1; - video_stream->codec->height = window_pixmap.texture_height & ~1; + //video_stream->codec->width = window_pixmap.texture_width & ~1; + //video_stream->codec->height = window_pixmap.texture_height & ~1; cuGraphicsUnregisterResource(cuda_graphics_resource); res = cuGraphicsGLRegisterImage(