aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXnipS <realxnips@gmail.com>2023-04-18 16:25:03 +1000
committerdec05eba <dec05eba@protonmail.com>2023-04-18 18:32:04 +0200
commite985e8e18ee735ea46b1a2807dbbab1928fb493b (patch)
tree50815bab3021b9d2e01a48ae9b205cdc49a09fcf
parenta99baa68727fbc73a06a653a33133ff9b75e3220 (diff)
Made fps update toggleable
-rw-r--r--src/main.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4b4c27b..0cc6922 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -633,7 +633,7 @@ static void open_video(AVCodecContext *codec_context, VideoQuality video_quality
}
static void usage() {
- fprintf(stderr, "usage: gpu-screen-recorder -w <window_id|monitor|focused> [-c <container_format>] [-s WxH] -f <fps> [-a <audio_input>] [-q <quality>] [-r <replay_buffer_size_sec>] [-k h264|h265] [-ac aac|opus|flac] [-oc yes|no] [-o <output_file>]\n");
+ fprintf(stderr, "usage: gpu-screen-recorder -w <window_id|monitor|focused> [-c <container_format>] [-s WxH] -f <fps> [-a <audio_input>] [-q <quality>] [-r <replay_buffer_size_sec>] [-k h264|h265] [-ac aac|opus|flac] [-oc yes|no] [-v yes|no] [-o <output_file>]\n");
fprintf(stderr, "\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " -w Window to record, a display, \"screen\", \"screen-direct\", \"screen-direct-force\" or \"focused\".\n");
@@ -673,6 +673,8 @@ static void usage() {
fprintf(stderr, " is dropped when you record a game. Only needed if you are recording a game that is bottlenecked by GPU.\n");
fprintf(stderr, " Works only if your have \"Coolbits\" set to \"12\" in NVIDIA X settings, see README for more information. Note! use at your own risk! Optional, disabled by default\n");
fprintf(stderr, "\n");
+ fprintf(stderr, " -v Prints per second, fps updates. Optional, set to 'yes' by default.\n");
+ fprintf(stderr, "\n");
//fprintf(stderr, " -pixfmt The pixel format to use for the output video. yuv420 is the most common format and is best supported, but the color is compressed, so colors can look washed out and certain colors of text can look bad. Use yuv444 for no color compression, but the video may not work everywhere and it may not work with hardware video decoding. Optional, defaults to yuv420\n");
fprintf(stderr, " -o The output file path. If omitted then the encoded data is sent to stdout. Required in replay mode (when using -r).\n");
fprintf(stderr, " In replay mode this has to be an existing directory instead of a file.\n");
@@ -1079,7 +1081,8 @@ int main(int argc, char **argv) {
{ "-k", Arg { {}, true, false } },
{ "-ac", Arg { {}, true, false } },
{ "-oc", Arg { {}, true, false } },
- { "-pixfmt", Arg { {}, true, false } }
+ { "-pixfmt", Arg { {}, true, false } },
+ { "-v", Arg { {}, true, false } },
};
for(int i = 1; i < argc; i += 2) {
@@ -1153,6 +1156,20 @@ int main(int argc, char **argv) {
usage();
}
+ bool verbose = true;
+ const char *verbose_str = args["-v"].value();
+ if(!verbose_str)
+ verbose_str = "yes";
+
+ if(strcmp(verbose_str, "yes") == 0) {
+ verbose = true;
+ } else if(strcmp(verbose_str, "no") == 0) {
+ verbose = false;
+ } else {
+ fprintf(stderr, "Error: -v should either be either 'yes' or 'no', got: '%s'\n", verbose_str);
+ usage();
+ }
+
PixelFormat pixel_format = PixelFormat::YUV420;
const char *pixfmt = args["-pixfmt"].value();
if(!pixfmt)
@@ -1891,7 +1908,9 @@ int main(int argc, char **argv) {
double frame_timer_elapsed = time_now - frame_timer_start;
double elapsed = time_now - start_time;
if (elapsed >= 1.0) {
- fprintf(stderr, "update fps: %d\n", fps_counter);
+ if(verbose) {
+ fprintf(stderr, "update fps: %d\n", fps_counter);
+ }
start_time = time_now;
fps_counter = 0;
}