aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-04-18 18:41:06 +0200
committerdec05eba <dec05eba@protonmail.com>2023-04-18 18:41:06 +0200
commit03ef7d0964944c058c34b6b1e2bb8bbf5f5a8e24 (patch)
tree75ecca1fa159155e9c706353afaca3bf696f89cf /src/main.cpp
parent7749ba83279cd974e319e999a72705ae04997360 (diff)
Show shorter form of help on argument error
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a7db997..05db5b0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -632,8 +632,12 @@ 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] [-v yes|no] [-o <output_file>]\n");
+static void usage_header() {
+ 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] [-h|--help] [-o <output_file>]\n");
+}
+
+static void usage_full() {
+ usage_header();
fprintf(stderr, "\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " -w Window to record, a display, \"screen\", \"screen-direct\", \"screen-direct-force\" or \"focused\".\n");
@@ -671,10 +675,12 @@ static void usage() {
fprintf(stderr, "\n");
fprintf(stderr, " -oc Overclock memory transfer rate to the maximum performance level. This only applies to NVIDIA and exists to overcome a bug in NVIDIA driver where performance level\n");
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, " 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, " -h Show this help.\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");
@@ -690,6 +696,11 @@ static void usage() {
exit(1);
}
+static void usage() {
+ usage_header();
+ exit(1);
+}
+
static sig_atomic_t running = 1;
static sig_atomic_t save_replay = 0;
@@ -1064,8 +1075,11 @@ int main(int argc, char **argv) {
signal(SIGINT, int_handler);
signal(SIGUSR1, save_replay_handler);
- if(argc == 0)
- usage();
+ if(argc <= 1)
+ usage_full();
+
+ if(argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0))
+ usage_full();
//av_log_set_level(AV_LOG_TRACE);