Show shorter form of help on argument error

This commit is contained in:
dec05eba 2023-04-18 18:41:06 +02:00
parent 7749ba8327
commit 03ef7d0964
2 changed files with 19 additions and 6 deletions

1
TODO
View File

@ -45,7 +45,6 @@ Better configure vaapi. The file size is too large.
Better colors for vaapi. It looks a bit off when recording vscode for example. Better colors for vaapi. It looks a bit off when recording vscode for example.
Clear vaapi surface (for focused window). Clear vaapi surface (for focused window).
Support -h and --help. -h should only show the first line and --help the full help. On error, only show that -h.
Window capture performance on steam deck isn't good when playing the witcher 3 for example. The capture itself is fine but video encoding puts it to 30fps even if the game runs at 57 fps. Window capture performance on steam deck isn't good when playing the witcher 3 for example. The capture itself is fine but video encoding puts it to 30fps even if the game runs at 57 fps.

View File

@ -632,8 +632,12 @@ static void open_video(AVCodecContext *codec_context, VideoQuality video_quality
} }
} }
static void usage() { 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] [-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] [-h|--help] [-o <output_file>]\n");
}
static void usage_full() {
usage_header();
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "OPTIONS:\n"); fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " -w Window to record, a display, \"screen\", \"screen-direct\", \"screen-direct-force\" or \"focused\".\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, "\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, " -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, " 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, "\n");
fprintf(stderr, " -v Prints per second, fps updates. Optional, set to 'yes' by default.\n"); fprintf(stderr, " -v Prints per second, fps updates. Optional, set to 'yes' by default.\n");
fprintf(stderr, "\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, " -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, " -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"); 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); exit(1);
} }
static void usage() {
usage_header();
exit(1);
}
static sig_atomic_t running = 1; static sig_atomic_t running = 1;
static sig_atomic_t save_replay = 0; static sig_atomic_t save_replay = 0;
@ -1064,8 +1075,11 @@ int main(int argc, char **argv) {
signal(SIGINT, int_handler); signal(SIGINT, int_handler);
signal(SIGUSR1, save_replay_handler); signal(SIGUSR1, save_replay_handler);
if(argc == 0) if(argc <= 1)
usage(); usage_full();
if(argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0))
usage_full();
//av_log_set_level(AV_LOG_TRACE); //av_log_set_level(AV_LOG_TRACE);