Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ The man page can be read with `man ./manpage/wf-recorder.1`.
In its simplest form, run `wf-recorder` to start recording and use Ctrl+C to stop. This will create a file called `recording.mp4` in the current working directory using the default codec.

Use `-f <filename>` to specify the output file. In case of multiple outputs, you'll first be prompted to select the output you want to record. If you know the output name beforehand, you can use the `-o <output name>` option.
To view all available output options, use the list flag `-L` or `--list-output`

To select a specific part of the screen you can either use `-g <geometry>`, or use [slurp](https://github.com/emersion/slurp) for interactive selection of the screen area that will be recorded:

Expand Down
4 changes: 4 additions & 0 deletions manpage/wf-recorder.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
.Op Fl h, -help
.Op Fl l, -log
.Op Fl m, -muxer Ar muxer
.Op Fl L, -list-output
.Op Fl o, -output Ar output
.Op Fl p, -codec-param Op Ar option_param=option_value
.Op Fl v, -version
Expand Down Expand Up @@ -133,6 +134,9 @@ Generates a log on the current terminal. For debug purposes.
.It Fl m , -muxer Ar muxer
Set the output format to a specific muxer instead of detecting it from the filename.
.Pp
.It Fl L , -list-output
List the available outputs.
.Pp
.It Fl o , -output
Specify the output where the video is to be recorded.
.Pp
Expand Down
56 changes: 42 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,16 +744,23 @@ static void load_output_info()
sync_wayland();
}

static wf_recorder_output* choose_interactive()
static void print_available_outputs()
{
fprintf(stdout, "Please select an output from the list to capture (enter output no.):\n");

int i = 1;
for (auto& wo : available_outputs)
{
printf("%d. Name: %s Description: %s\n", i++, wo.name.c_str(),
wo.description.c_str());
}
}



static wf_recorder_output* choose_interactive()
{
fprintf(stdout, "Please select an output from the list to capture (enter output no.):\n");

print_available_outputs();

printf("Enter output no.:");
fflush(stdout);
Expand Down Expand Up @@ -881,6 +888,8 @@ Use Ctrl+C to stop.)");

-l, --log Generates a log on the current terminal. Debug purposes.

-L, --list-output List the available outputs.

-o, --output Specify the output where the video is to be recorded.

-p, --codec-param Change the codec parameters.
Expand Down Expand Up @@ -989,6 +998,29 @@ static void parse_codec_opts(std::map<std::string, std::string>& options, const
}
}

static void init_wayland_client()
{
display = wl_display_connect(NULL);
if (display == NULL)
{
fprintf(stderr, "failed to create display: %m\n");
exit(EXIT_FAILURE);
}
struct wl_registry *registry = wl_display_get_registry(display);
wl_registry_add_listener(registry, &registry_listener, NULL);
sync_wayland();
}

static void list_available_outputs()
{
init_wayland_client();
load_output_info();
print_available_outputs();

exit(EXIT_SUCCESS);
}


int main(int argc, char *argv[])
{
FrameWriterParams params = FrameWriterParams(exit_main_loop);
Expand Down Expand Up @@ -1031,11 +1063,12 @@ int main(int argc, char *argv[])
{ "version", no_argument, NULL, 'v' },
{ "no-damage", no_argument, NULL, 'D' },
{ "overwrite", no_argument, NULL, 'y' },
{ "list-output", no_argument, NULL, 'L' },
{ 0, 0, NULL, 0 }
};

int c, i;
while((c = getopt_long(argc, argv, "o:f:m:g:c:p:r:x:C:P:R:X:d:b:B:la::hvDF:y", opts, &i)) != -1)
while((c = getopt_long(argc, argv, "o:f:m:g:c:p:r:x:C:P:R:X:d:b:B:la::hvDF:y:L", opts, &i)) != -1)
{
switch(c)
{
Expand Down Expand Up @@ -1136,6 +1169,10 @@ int main(int argc, char *argv[])
case 'y':
force_overwrite = true;
break;

case 'L':
list_available_outputs();
break;
#ifdef HAVE_AUDIO
case '*':
audioParams.audio_backend = optarg;
Expand All @@ -1151,16 +1188,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

display = wl_display_connect(NULL);
if (display == NULL)
{
fprintf(stderr, "failed to create display: %m\n");
return EXIT_FAILURE;
}

struct wl_registry *registry = wl_display_get_registry(display);
wl_registry_add_listener(registry, &registry_listener, NULL);
sync_wayland();
init_wayland_client();

if (params.codec.find("vaapi") != std::string::npos)
{
Expand Down