aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README6
-rw-r--r--main.c22
-rw-r--r--render.c7
-rw-r--r--render.h2
4 files changed, 22 insertions, 15 deletions
diff --git a/README b/README
index 168b6a1..3e7f87f 100644
--- a/README
+++ b/README
@@ -4,10 +4,10 @@ rendertools
orange box engine demo renderer
usage:
- rt -w <width> -h <height> -g <game> -r <fps> [-1] [-q <quality>] [-b <bitrate>]
- path/to/output.mp4 path/to/demo1.dem [path/to/demo2.dem...]
+ rt [-w <width>] [-h <height>] [-g <game>] [-r <fps>] [-s <qvs>] [-1] [-q <quality>] OR [-b <bitrate>]
+ path/to/video.mp4 path/to/demo1.dem...
--1 flag combines multiple renders into 1 file
+-1 flag combines multiple renders into 1 file (UNIMPLEMENTED)
bitrate is in kbps, quality 1-100
cannot specify quality and bitrate at the same time
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 <width> -h <height> -g <game> -r <fps> [-q <quality>] [-b <bitrate>]\n"
+ " rt [-w <width>] [-h <height>] [-g <game>] [-r <fps>] [-s <qvs>] [-1] [-q <quality>] OR [-b <bitrate>]\n"
" path/to/video.mp4 path/to/demo1.dem...\n");
exit(1);
}
diff --git a/render.c b/render.c
index 495a918..4b633a4 100644
--- a/render.c
+++ b/render.c
@@ -101,7 +101,7 @@ void VIRTUAL hook_stop_playback(struct demoplayer *this) {
}
bool render_init(int width, int height, int framerate, bool use_bitrate,
- int quality, const char *output_file) {
+ int quality, const char *output_file, int qvs) {
bool r =
os_mprot((*videomode)->vt, 28 * sizeof(void *), PAGE_EXECUTE_READWRITE);
if (!r) bail("couldn't mprotect videomode vtable");
@@ -178,9 +178,8 @@ bool render_init(int width, int height, int framerate, bool use_bitrate,
VARIANT _quality = { .vt = VT_UI4, .ulVal = quality };
HR(codec->lpVtbl->SetValue(codec, &CODECAPI_AVEncCommonQuality, &_quality));
- // even at 100 it is still very quick, really no reason to change it
- VARIANT qvs = { .vt = VT_UI4, .ulVal = 100 };
- HR(codec->lpVtbl->SetValue(codec, &CODECAPI_AVEncCommonQualityVsSpeed, &qvs));
+ VARIANT _qvs = { .vt = VT_UI4, .ulVal = qvs };
+ HR(codec->lpVtbl->SetValue(codec, &CODECAPI_AVEncCommonQualityVsSpeed, &_qvs));
// set the gop size to 2 seconds
VARIANT gop = { .vt = VT_UI4, .ulVal = 2 * ctx.fps };
diff --git a/render.h b/render.h
index bec043b..49ccce3 100644
--- a/render.h
+++ b/render.h
@@ -21,7 +21,7 @@
#include <mfreadwrite.h>
bool render_init(int width, int height, int framerate, bool use_bitrate,
- int quality, const char *output_file);
+ int quality, const char *output_file, int qvs);
struct renderctx {
int width;