mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-04-01 17:32:47 +09:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
422f214283 | ||
|
|
768f1bd61e | ||
|
|
7428f9ffee | ||
|
|
10165977f6 | ||
|
|
62509a4b60 |
@@ -183,6 +183,40 @@ static void file_get_directory(char *filepath) {
|
||||
*end = '\0';
|
||||
}
|
||||
|
||||
static bool find_program_in_path(const char *program_name, char *filepath, int filepath_len) {
|
||||
const char *path = getenv("PATH");
|
||||
if(!path)
|
||||
return false;
|
||||
|
||||
int program_name_len = strlen(program_name);
|
||||
const char *end = path + strlen(path);
|
||||
while(path != end) {
|
||||
const char *part_end = strchr(path, ':');
|
||||
const char *next = part_end;
|
||||
if(part_end) {
|
||||
next = part_end + 1;
|
||||
} else {
|
||||
part_end = end;
|
||||
next = end;
|
||||
}
|
||||
|
||||
int len = part_end - path;
|
||||
if(len + 1 + program_name_len < filepath_len) {
|
||||
memcpy(filepath, path, len);
|
||||
filepath[len] = '/';
|
||||
memcpy(filepath + len + 1, program_name, program_name_len);
|
||||
filepath[len + 1 + program_name_len] = '\0';
|
||||
|
||||
if(access(filepath, F_OK) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
path = next;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
|
||||
int result = -1;
|
||||
self->kms_server_pid = -1;
|
||||
@@ -212,8 +246,11 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
|
||||
}
|
||||
|
||||
if(access(server_filepath, F_OK) != 0) {
|
||||
fprintf(stderr, "gsr error: gsr_kms_client_init: gsr-kms-server is not installed (%s not found)\n", server_filepath);
|
||||
return -1;
|
||||
fprintf(stderr, "gsr info: gsr_kms_client_init: gsr-kms-server is not installed in the same directory as gpu-screen-recorder (%s not found), looking for gsr-kms-server in PATH instead\n", server_filepath);
|
||||
if(!find_program_in_path("gsr-kms-server", server_filepath, sizeof(server_filepath)) || access(server_filepath, F_OK) != 0) {
|
||||
fprintf(stderr, "gsr error: gsr_kms_client_init: gsr-kms-server was not found in PATH. Please install gpu-screen-recorder properly\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "gsr info: gsr_kms_client_init: setting up connection to %s\n", server_filepath);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
project('gpu-screen-recorder', ['c', 'cpp'], version : '4.2.2', default_options : ['warning_level=2'])
|
||||
project('gpu-screen-recorder', ['c', 'cpp'], version : '4.2.4', default_options : ['warning_level=2'])
|
||||
|
||||
add_project_arguments('-Wshadow', language : ['c', 'cpp'])
|
||||
if get_option('buildtype') == 'debug'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "gpu-screen-recorder"
|
||||
type = "executable"
|
||||
version = "4.2.2"
|
||||
version = "4.2.4"
|
||||
platforms = ["posix"]
|
||||
|
||||
[config]
|
||||
|
||||
45
src/main.cpp
45
src/main.cpp
@@ -989,7 +989,7 @@ static void open_video_hardware(AVCodecContext *codec_context, VideoQuality vide
|
||||
// TODO: Enable multipass
|
||||
|
||||
if(vendor == GSR_GPU_VENDOR_NVIDIA) {
|
||||
// TODO: Test these, if they are needed, if they should be used
|
||||
// TODO: These dont seem to be necessary
|
||||
// av_dict_set_int(&options, "zerolatency", 1, 0);
|
||||
// if(codec_context->codec_id == AV_CODEC_ID_AV1) {
|
||||
// av_dict_set(&options, "tune", "ll", 0);
|
||||
@@ -1162,7 +1162,7 @@ static void usage_full() {
|
||||
fprintf(stderr, " Note: the directory to the portal session token file is created automatically if it doesn't exist.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -encoder\n");
|
||||
fprintf(stderr, " Which device should be used for video encoding. Should either be 'gpu' or 'cpu'. Does currently only work with h264 codec option (-k).\n");
|
||||
fprintf(stderr, " Which device should be used for video encoding. Should either be 'gpu' or 'cpu'. 'cpu' option currently only work with h264 codec option (-k).\n");
|
||||
fprintf(stderr, " Optional, set to 'gpu' by default.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " --info\n");
|
||||
@@ -1177,6 +1177,7 @@ static void usage_full() {
|
||||
fprintf(stderr, " For example:\n");
|
||||
fprintf(stderr, " bluez_input.88:C9:E8:66:A2:27|WH-1000XM4\n");
|
||||
fprintf(stderr, " The <audio_device_name> is the name to pass to GPU Screen Recorder in a -a option.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " --version\n");
|
||||
fprintf(stderr, " Print version (%s) and exit\n", GSR_VERSION);
|
||||
fprintf(stderr, "\n");
|
||||
@@ -1185,7 +1186,7 @@ static void usage_full() {
|
||||
fprintf(stderr, " In replay mode this has to be a directory instead of a file.\n");
|
||||
fprintf(stderr, " Note: the directory to the file is created automatically if it doesn't already exist.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -v Prints per second, fps updates. Optional, set to 'yes' by default.\n");
|
||||
fprintf(stderr, " -v Prints fps and damage info once per second. Optional, set to 'yes' by default.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -h, --help\n");
|
||||
fprintf(stderr, " Show this help.\n");
|
||||
@@ -1580,16 +1581,27 @@ static void split_string(const std::string &str, char delimiter, std::function<b
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<AudioInput> parse_audio_input_arg(const char *str) {
|
||||
static const AudioInput* get_audio_device_by_name(const std::vector<AudioInput> &audio_inputs, const std::string &name) {
|
||||
for(const auto &audio_input : audio_inputs) {
|
||||
if(audio_input.name == name)
|
||||
return &audio_input;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static std::vector<AudioInput> parse_audio_input_arg(const char *str, const AudioDevices &audio_devices) {
|
||||
std::vector<AudioInput> audio_inputs;
|
||||
split_string(str, '|', [&audio_inputs](const char *sub, size_t size) {
|
||||
split_string(str, '|', [&](const char *sub, size_t size) {
|
||||
AudioInput audio_input;
|
||||
audio_input.name.assign(sub, size);
|
||||
|
||||
const bool name_is_existing_audio_device = get_audio_device_by_name(audio_devices.audio_inputs, audio_input.name);
|
||||
const size_t index = audio_input.name.find('/');
|
||||
if(index != std::string::npos) {
|
||||
if(!name_is_existing_audio_device && index != std::string::npos) {
|
||||
audio_input.description = audio_input.name.substr(0, index);
|
||||
audio_input.name.erase(audio_input.name.begin(), audio_input.name.begin() + index + 1);
|
||||
}
|
||||
|
||||
audio_inputs.push_back(std::move(audio_input));
|
||||
return true;
|
||||
});
|
||||
@@ -2264,7 +2276,7 @@ static std::vector<MergedAudioInputs> parse_audio_inputs(const AudioDevices &aud
|
||||
if(!audio_input || audio_input[0] == '\0')
|
||||
continue;
|
||||
|
||||
requested_audio_inputs.push_back({parse_audio_input_arg(audio_input)});
|
||||
requested_audio_inputs.push_back({parse_audio_input_arg(audio_input, audio_devices)});
|
||||
if(requested_audio_inputs.back().audio_inputs.size() > 1)
|
||||
uses_amix = true;
|
||||
|
||||
@@ -2285,14 +2297,11 @@ static std::vector<MergedAudioInputs> parse_audio_inputs(const AudioDevices &aud
|
||||
match = true;
|
||||
}
|
||||
|
||||
for(const auto &existing_audio_input : audio_devices.audio_inputs) {
|
||||
if(request_audio_input.name == existing_audio_input.name) {
|
||||
if(request_audio_input.description.empty())
|
||||
request_audio_input.description = "gsr-" + existing_audio_input.description;
|
||||
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
const AudioInput* existing_audio_input = get_audio_device_by_name(audio_devices.audio_inputs, request_audio_input.name);
|
||||
if(existing_audio_input) {
|
||||
if(request_audio_input.description.empty())
|
||||
request_audio_input.description = "gsr-" + existing_audio_input->description;
|
||||
match = true;
|
||||
}
|
||||
|
||||
if(!match) {
|
||||
@@ -2301,8 +2310,8 @@ static std::vector<MergedAudioInputs> parse_audio_inputs(const AudioDevices &aud
|
||||
fprintf(stderr, " default_output (Default output)\n");
|
||||
if(!audio_devices.default_input.empty())
|
||||
fprintf(stderr, " default_input (Default input)\n");
|
||||
for(const auto &existing_audio_input : audio_devices.audio_inputs) {
|
||||
fprintf(stderr, " %s (%s)\n", existing_audio_input.name.c_str(), existing_audio_input.description.c_str());
|
||||
for(const auto &audio_input : audio_devices.audio_inputs) {
|
||||
fprintf(stderr, " %s (%s)\n", audio_input.name.c_str(), audio_input.description.c_str());
|
||||
}
|
||||
_exit(2);
|
||||
}
|
||||
@@ -2609,7 +2618,7 @@ int main(int argc, char **argv) {
|
||||
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 on july 17, 2024.
|
||||
// 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?
|
||||
|
||||
Reference in New Issue
Block a user