aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--TODO2
-rw-r--r--kms/client/kms_client.c6
-rw-r--r--src/main.cpp18
4 files changed, 21 insertions, 7 deletions
diff --git a/README.md b/README.md
index 1883558..d9cd54c 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ Streaming works the same as recording, but the `-o` argument should be path to t
Run `gpu-screen-recorder` with the `-c mp4` and `-r` option, for example: `gpu-screen-recorder -w screen -f 60 -r 30 -c mp4 -o ~/Videos`. Note that in this case, `-o` should point to a directory.\
If `-mf yes` is set, replays are save in folders based on the date.
To save a video in replay mode, you need to send signal SIGUSR1 to gpu screen recorder. You can do this by running `killall -SIGUSR1 gpu-screen-recorder`.\
-To stop recording, send SIGINT to gpu screen recorder. You can do this by running `killall gpu-screen-recorder` or pressing `Ctrl-C` in the terminal that runs gpu screen recorder.\
+To stop recording, send SIGINT to gpu screen recorder. You can do this by running `killall -SIGINT gpu-screen-recorder` or pressing `Ctrl-C` in the terminal that runs gpu screen recorder.\
The file path to the saved replay is output to stdout. All other output from GPU Screen Recorder is output to stderr.
## Finding audio device name
You can find the default output audio device (headset, speakers (in other words, desktop audio)) with the command `pactl get-default-sink`. Add `monitor` to the end of that to use that as an audio input in gpu screen recorder.\
diff --git a/TODO b/TODO
index c7d3a75..a85a131 100644
--- a/TODO
+++ b/TODO
@@ -110,3 +110,5 @@ Test if p2 state can be worked around by using pure nvenc api and overwriting cu
Mesa doesn't support global headers (AV_CODEC_FLAG_GLOBAL_HEADER) with h264... which also breaks mkv since mkv requires global header. Right now gpu screen recorder will forcefully set video codec to hevc when h264 is requested for mkv files.
Drop frames if live streaming cant keep up with target fps, or dynamically change resolution/quality.
+
+Support low power option (does it even work with vaapi in ffmpeg??). Would be very useful for steam deck. \ No newline at end of file
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c
index fe19023..02dce0b 100644
--- a/kms/client/kms_client.c
+++ b/kms/client/kms_client.c
@@ -232,7 +232,7 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
strncpy_safe(local_addr.sun_path, self->initial_socket_path, sizeof(local_addr.sun_path));
const mode_t prev_mask = umask(0000);
- int bind_res = bind(self->initial_socket_fd, (struct sockaddr*)&local_addr, sizeof(local_addr.sun_family) + strlen(local_addr.sun_path));
+ const int bind_res = bind(self->initial_socket_fd, (struct sockaddr*)&local_addr, sizeof(local_addr.sun_family) + strlen(local_addr.sun_path));
umask(prev_mask);
if(bind_res == -1) {
@@ -260,8 +260,8 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
// If above fails for whatever reason we try this. Maybe some distros dont install flatpak in /var/lib/flatpak/app ?
{
- const char *args[] = { "flatpak-spawn", "--host", "pkexec", "flatpak", "run", "--command=gsr-kms-server", "com.dec05eba.gpu_screen_recorder", self->initial_socket_path, card_path, NULL };
- execvp(args[0], (char *const*)args);
+ const char *args2[] = { "flatpak-spawn", "--host", "pkexec", "flatpak", "run", "--command=gsr-kms-server", "com.dec05eba.gpu_screen_recorder", self->initial_socket_path, card_path, NULL };
+ execvp(args2[0], (char *const*)args2);
}
}
} else if(has_perm) {
diff --git a/src/main.cpp b/src/main.cpp
index 9afb631..e0445dd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -21,6 +21,7 @@ extern "C" {
#include <sys/stat.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <libgen.h>
#include "../include/sound.hpp"
@@ -832,12 +833,13 @@ static void usage_full() {
//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, " In replay mode this has to be a directory instead of a file.\n");
+ fprintf(stderr, " The directory to the file is created (recursively) if it doesn't already exist.\n");
fprintf(stderr, "\n");
fprintf(stderr, "NOTES:\n");
- fprintf(stderr, " Send signal SIGINT to gpu-screen-recorder (Ctrl+C, or killall gpu-screen-recorder) to stop and save the recording (when not using replay mode).\n");
+ fprintf(stderr, " Send signal SIGINT to gpu-screen-recorder (Ctrl+C, or killall -SIGINT gpu-screen-recorder) to stop and save the recording (when not using replay mode).\n");
fprintf(stderr, " Send signal SIGUSR1 to gpu-screen-recorder (killall -SIGUSR1 gpu-screen-recorder) to save a replay (when in replay mode).\n");
fprintf(stderr, "\n");
- fprintf(stderr, "EXAMPLES\n");
+ fprintf(stderr, "EXAMPLES:\n");
fprintf(stderr, " gpu-screen-recorder -w screen -f 60 -a \"$(pactl get-default-sink).monitor\" -o video.mp4\n");
fprintf(stderr, " gpu-screen-recorder -w screen -f 60 -a \"$(pactl get-default-sink).monitor|$(pactl get-default-source)\" -o video.mp4\n");
//fprintf(stderr, " gpu-screen-recorder -w screen -f 60 -q ultra -pixfmt yuv444 -o video.mp4\n");
@@ -1872,7 +1874,17 @@ int main(int argc, char **argv) {
const char *filename = args["-o"].value();
if(filename) {
- if(replay_buffer_size_secs != -1) {
+ if(replay_buffer_size_secs == -1) {
+ char directory_buf[PATH_MAX];
+ strcpy(directory_buf, filename);
+ char *directory = dirname(directory_buf);
+ if(strcmp(directory, ".") != 0 && strcmp(directory, "/") != 0) {
+ if(create_directory_recursive(directory) != 0) {
+ fprintf(stderr, "Error: failed to create directory for output file: %s\n", filename);
+ _exit(1);
+ }
+ }
+ } else {
if(!container_format) {
fprintf(stderr, "Error: option -c is required when using option -r\n");
usage();