Call -sc script on screenshot as well, only save screenshot if no error

This commit is contained in:
dec05eba
2025-08-24 21:07:58 +02:00
parent 48932dfdfb
commit 5a93d292ea
5 changed files with 16 additions and 8 deletions

View File

@@ -161,7 +161,7 @@ You can see which variables that you can use in the `gpu-screen-recorder.env` fi
You can use the `scripts/save-replay.sh` script to save a replay and by default the systemd service saves videos in `$HOME/Videos`.
## Run a script when a video is saved
Run `gpu-screen-recorder` with the `-sc` option to specify a script that should be run when a recording/replay a saved, for example `gpu-screen-recorder -w screen -sc ./script.sh -o video.mp4`.\
The first argument to the script is the file path to the saved video. The second argument is either "regular" for regular recordings and "replay" for replays.\
The first argument to the script is the file path to the saved video. The second argument is either "regular" for regular recordings, "replay" for replays or "screenshot" for screenshots.\
This can be used to for example showing a notification with the name of video or moving a video to a folder based on the name of the game that was recorded.
## Plugins
GPU Screen Recorder supports plugins for rendering additional graphics on top of the monitor/window capture. The plugin interface is defined in `plugin/plugin.h` and it gets installed to `gsr/plugin.h` in the systems include directory (usually `/usr/include`).

4
TODO
View File

@@ -321,4 +321,6 @@ kde plasma portal capture for screenshot doesn't work well because the portal ui
It's possible for microphone audio to get desynced when recording together with desktop audio, when not recording app audio as well.
Test recording desktop audio and microphone audio together (-a "default_output|default_input") for around 30 minutes.
We can use dri2connect/dri3open to get the /dev/dri/card device. Note that this doesn't work on nvidia x11.
We can use dri2connect/dri3open to get the /dev/dri/card device. Note that this doesn't work on nvidia x11.
Add support for QVBR (QP with target bitrate).

View File

@@ -311,7 +311,7 @@ static void usage_full() {
printf("\n");
printf(" -df Organise replays in folders based on the current date.\n");
printf("\n");
printf(" -sc Run a script on the saved video file (asynchronously). The first argument to the script is the filepath to the saved video file and the second argument is the recording type (either \"regular\" or \"replay\").\n");
printf(" -sc Run a script on the saved video file (asynchronously). The first argument to the script is the filepath to the saved video/screenshot file and the second argument is the recording type (either \"regular\", \"replay\" or \"screenshot\").\n");
printf(" Not applicable for live streams.\n");
printf(" Note: the script has to be executable.\n");
printf("\n");

View File

@@ -65,6 +65,7 @@ bool gsr_cuda_load(gsr_cuda *self, Display *display, bool do_overclock) {
goto fail;
}
// TODO: Use the device associated with the opengl graphics context
CUdevice cu_dev;
res = self->cuDeviceGet(&cu_dev, 0);
if(res != CUDA_SUCCESS) {

View File

@@ -2347,11 +2347,16 @@ static void capture_image_to_file(args_parser &arg_parser, gsr_egl *egl, gsr_ima
}
gsr_egl_swap_buffers(egl);
const int image_quality = video_quality_to_image_quality_value(arg_parser.video_quality);
if(!gsr_image_writer_write_to_file(&image_writer, arg_parser.filename, image_format, image_quality)) {
fprintf(stderr, "gsr error: capture_image_to_file_wayland: failed to write opengl texture to image output file %s\n", arg_parser.filename);
_exit(1);
if(!should_stop_error) {
const int image_quality = video_quality_to_image_quality_value(arg_parser.video_quality);
if(!gsr_image_writer_write_to_file(&image_writer, arg_parser.filename, image_format, image_quality)) {
fprintf(stderr, "gsr error: capture_image_to_file_wayland: failed to write opengl texture to image output file %s\n", arg_parser.filename);
_exit(1);
}
if(arg_parser.recording_saved_script)
run_recording_saved_script_async(arg_parser.recording_saved_script, arg_parser.filename, "screenshot");
}
gsr_image_writer_deinit(&image_writer);