From 3c19c509af38424cd04df53e1af7ef1b20a191ef Mon Sep 17 00:00:00 2001 From: Matthew Wozniak Date: Mon, 4 Nov 2024 11:11:57 -0500 Subject: allow the user to change the quality vs speed setting --- main.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index a8b5725..3d89c08 100644 --- a/main.c +++ b/main.c @@ -33,6 +33,7 @@ struct { int fps; int quality; int bitrate; + int qvs; char *out; char **demo; bool combine; @@ -45,7 +46,7 @@ void hook_cbuf_addtext(char *str) { if (!strcmp(str, "exec modsettings.cfg mod\n")) { bool use_bitrate = !!args.bitrate; if (!render_init(args.width, args.height, args.fps, use_bitrate, - use_bitrate ? args.bitrate : args.quality, args.out)) + use_bitrate ? args.bitrate : args.quality, args.out, args.qvs)) die("couldn't init render"); // play the demo demoplayer->vt->start_playback(demoplayer, args.demo[0], false); @@ -84,11 +85,11 @@ int main(int argc, char **argv) { SetDllDirectoryA("bin/"); int c; char *strend; - while ((c = getopt(argc, argv, "w:h:g:r:q:b:")) != -1) { + while ((c = getopt(argc, argv, "w:h:g:r:q:b:s:")) != -1) { switch (c) { case 'w': args.width = strtol(optarg, &strend, 10); - if (strend == optarg) die("width must be a number!"); + if (strend == optarg) die("width must be a number"); break; case 'h': args.height = strtol(optarg, &strend, 10); @@ -96,15 +97,21 @@ int main(int argc, char **argv) { break; case 'r': args.fps = strtol(optarg, &strend, 10); - if (strend == optarg) die("must pass a number to -w!"); + if (strend == optarg) die("fps must be a number"); break; case 'q': args.quality = strtol(optarg, &strend, 10); - if (strend == optarg) die("must pass a number to -w!"); + if (strend == optarg || args.quality < 1 || args.quality > 100) + die("quality must be a number 1-100"); + break; + case 's': + args.qvs = strtol(optarg, &strend, 10); + if (strend == optarg || args.qvs < 1 || args.qvs > 100) + die("qvs must be a number 1-100"); break; case 'b': args.bitrate = strtol(optarg, &strend, 10); - if (strend == optarg) die("must pass a number to -w!"); + if (strend == optarg) die("bitrate must be a number"); break; case 'g': args.game = optarg; @@ -120,11 +127,12 @@ int main(int argc, char **argv) { if (!args.game) args.game = "hl2"; if (!args.fps) args.fps = 30; if (!args.quality) args.quality = 75; + if (!args.qvs) args.qvs = 100; if (argc - optind < 2) { printf( "usage:\n" - " rt -w -h -g -r [-q ] [-b ]\n" + " rt [-w ] [-h ] [-g ] [-r ] [-s ] [-1] [-q ] OR [-b ]\n" " path/to/video.mp4 path/to/demo1.dem...\n"); exit(1); } -- cgit v1.2.3-54-g00ecf