mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 09:07:13 +09:00
Add -low-power option to allow prevent the gpu to go into a high power mode on amd, useful for replay running 24/7
This commit is contained in:
@@ -197,7 +197,7 @@ static void usage_header(void) {
|
||||
"[-bm auto|qp|vbr|cbr] [-cr limited|full] [-tune performance|quality] [-df yes|no] [-sc <script_path>] [-p <plugin_path>] "
|
||||
"[-cursor yes|no] [-keyint <value>] [-restore-portal-session yes|no] [-portal-session-token-filepath filepath] [-encoder gpu|cpu] "
|
||||
"[-fallback-cpu-encoding yes|no] [-o <output_file>] [-ro <output_directory>] [-ffmpeg-opts <options>] [--list-capture-options [card_path]] "
|
||||
"[--list-audio-devices] [--list-application-audio] [--list-v4l2-devices] [-v yes|no] [-gl-debug yes|no] [--version] [-h|--help]\n", program_name);
|
||||
"[--list-audio-devices] [--list-application-audio] [--list-v4l2-devices] [-low-power yes|no] [-v yes|no] [-gl-debug yes|no] [--version] [-h|--help]\n", program_name);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -256,6 +256,7 @@ static bool args_parser_set_values(args_parser *self) {
|
||||
self->restart_replay_on_save = args_get_boolean_by_key(self->args, NUM_ARGS, "-restart-replay-on-save", false);
|
||||
self->overclock = args_get_boolean_by_key(self->args, NUM_ARGS, "-oc", false);
|
||||
self->fallback_cpu_encoding = args_get_boolean_by_key(self->args, NUM_ARGS, "-fallback-cpu-encoding", false);
|
||||
self->low_power = args_get_boolean_by_key(self->args, NUM_ARGS, "-low-power", false);
|
||||
|
||||
self->audio_bitrate = args_get_i64_by_key(self->args, NUM_ARGS, "-ab", 0);
|
||||
self->audio_bitrate *= 1000LL;
|
||||
@@ -536,6 +537,7 @@ bool args_parser_parse(args_parser *self, int argc, char **argv, const args_hand
|
||||
self->args[arg_index++] = (Arg){ .key = "-ffmpeg-opts", .optional = true, .list = false, .type = ARG_TYPE_STRING };
|
||||
self->args[arg_index++] = (Arg){ .key = "-ffmpeg-video-opts", .optional = true, .list = false, .type = ARG_TYPE_STRING };
|
||||
self->args[arg_index++] = (Arg){ .key = "-ffmpeg-audio-opts", .optional = true, .list = false, .type = ARG_TYPE_STRING };
|
||||
self->args[arg_index++] = (Arg){ .key = "-low-power", .optional = true, .list = false, .type = ARG_TYPE_BOOLEAN };
|
||||
assert(arg_index == NUM_ARGS);
|
||||
|
||||
for(int i = 1; i < argc; i += 2) {
|
||||
|
||||
16
src/main.cpp
16
src/main.cpp
@@ -3652,13 +3652,6 @@ int main(int argc, char **argv) {
|
||||
// If this is set to 1 then cuGraphicsGLRegisterImage will fail for egl context with error: invalid OpenGL or DirectX context,
|
||||
// so we overwrite it
|
||||
setenv("__GL_THREADED_OPTIMIZATIONS", "0", true);
|
||||
// Forces low latency encoding mode. Use this environment variable until vaapi supports setting this as a parameter.
|
||||
// The downside of this is that it always uses maximum power, which is not ideal for replay mode that runs on system startup.
|
||||
// This option was added in mesa 24.1.4, released in july 17, 2024.
|
||||
// TODO: Add an option to enable/disable this?
|
||||
// Seems like the performance issue is not in encoding, but rendering the frame.
|
||||
// Some frames end up taking 10 times longer. Seems to be an issue with amd gpu power management when letting the application sleep on the cpu side?
|
||||
setenv("AMD_DEBUG", "lowlatencyenc", true);
|
||||
// Some people set this to nvidia (for nvdec) or vdpau (for nvidia vdpau), which breaks gpu screen recorder since
|
||||
// nvidia doesn't support vaapi and nvidia-vaapi-driver doesn't support encoding yet.
|
||||
// Let vaapi find the right vaapi driver instead of forcing a specific one.
|
||||
@@ -3685,6 +3678,15 @@ int main(int argc, char **argv) {
|
||||
if(!args_parser_parse(&arg_parser, argc, argv, &arg_handlers, NULL))
|
||||
_exit(1);
|
||||
|
||||
if(!arg_parser.low_power) {
|
||||
// Forces low latency encoding mode. Use this environment variable until vaapi supports setting this as a parameter.
|
||||
// The downside of this is that it always uses maximum power, which is not ideal for replay mode that runs on system startup.
|
||||
// This option was added in mesa 24.1.4, released in july 17, 2024.
|
||||
// Seems like the performance issue is not in encoding, but rendering the frame.
|
||||
// Some frames end up taking 10 times longer. Seems to be an issue with amd gpu power management when letting the application sleep on the cpu side?
|
||||
setenv("AMD_DEBUG", "lowlatencyenc", true);
|
||||
}
|
||||
|
||||
std::vector<CaptureSource> capture_sources = parse_capture_source_arg(arg_parser.capture_source, arg_parser);
|
||||
if(capture_sources.empty()) {
|
||||
fprintf(stderr, "gsr error: option -w can't be empty. You need to capture video from at least one source\n");
|
||||
|
||||
Reference in New Issue
Block a user