mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
Command line parsing
This commit is contained in:
parent
b9b397ef80
commit
f204a9127c
1 changed files with 34 additions and 28 deletions
|
@ -35,7 +35,6 @@ struct capture_context {
|
||||||
|
|
||||||
/* Target */
|
/* Target */
|
||||||
struct wl_output *target_output;
|
struct wl_output *target_output;
|
||||||
uint32_t target_client;
|
|
||||||
|
|
||||||
/* Main frame callback */
|
/* Main frame callback */
|
||||||
struct zwlr_export_dmabuf_frame_v1 *frame_callback;
|
struct zwlr_export_dmabuf_frame_v1 *frame_callback;
|
||||||
|
@ -494,11 +493,10 @@ static int set_hwframe_ctx(struct capture_context *ctx,
|
||||||
frames_ctx->sw_format = ctx->avctx->pix_fmt;
|
frames_ctx->sw_format = ctx->avctx->pix_fmt;
|
||||||
frames_ctx->width = ctx->avctx->width;
|
frames_ctx->width = ctx->avctx->width;
|
||||||
frames_ctx->height = ctx->avctx->height;
|
frames_ctx->height = ctx->avctx->height;
|
||||||
frames_ctx->initial_pool_size = 16;
|
|
||||||
|
|
||||||
av_hwframe_constraints_free(&cst);
|
av_hwframe_constraints_free(&cst);
|
||||||
|
|
||||||
if ((err = av_hwframe_ctx_init(ctx->mapped_frames_ref)) < 0) {
|
if ((err = av_hwframe_ctx_init(ctx->mapped_frames_ref))) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to initialize hw frame context: %s!\n",
|
av_log(ctx, AV_LOG_ERROR, "Failed to initialize hw frame context: %s!\n",
|
||||||
av_err2str(err));
|
av_err2str(err));
|
||||||
av_buffer_unref(&ctx->mapped_frames_ref);
|
av_buffer_unref(&ctx->mapped_frames_ref);
|
||||||
|
@ -695,19 +693,6 @@ static int init(struct capture_context *ctx) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_capturable_surfaces(struct capture_context *ctx) {
|
|
||||||
|
|
||||||
struct wayland_output *o, *tmp_o;
|
|
||||||
wl_list_for_each_reverse_safe(o, tmp_o, &ctx->output_list, link) {
|
|
||||||
ctx->target_output = o->output; /* Default is first, whatever */
|
|
||||||
av_log(ctx, AV_LOG_INFO, "Capturable output: %s Model: %s:\n",
|
|
||||||
o->make, o->model);
|
|
||||||
}
|
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_INFO, "Capturing from output: %s!\n",
|
|
||||||
find_output(ctx, ctx->target_output, 0)->model);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void uninit(struct capture_context *ctx);
|
static void uninit(struct capture_context *ctx);
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -723,18 +708,39 @@ int main(int argc, char *argv[]) {
|
||||||
if (err)
|
if (err)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
print_capturable_surfaces(&ctx);
|
struct wayland_output *o, *tmp_o;
|
||||||
|
wl_list_for_each_reverse_safe(o, tmp_o, &ctx.output_list, link) {
|
||||||
|
printf("Capturable output: %s Model: %s: ID: %i\n",
|
||||||
|
o->make, o->model, o->id);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.hw_device_type = av_hwdevice_find_type_by_name("vaapi");
|
if (argc != 8) {
|
||||||
ctx.hardware_device = "/dev/dri/renderD128";
|
printf("Invalid number of arguments! Usage and example:\n"
|
||||||
|
"./dmabuf-capture <source id> <hardware device type> <device> "
|
||||||
|
"<encoder name> <pixel format> <bitrate in Mbps> <file path>\n"
|
||||||
|
"./dmabuf-capture 0 vaapi /dev/dri/renderD129 libx264 nv12 12 "
|
||||||
|
"dmabuf_recording_01.mkv\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int o_id = strtol(argv[1], NULL, 10);
|
||||||
|
o = find_output(&ctx, NULL, o_id);
|
||||||
|
if (!o) {
|
||||||
|
printf("Unable to find output with ID %i!\n", o_id);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.target_output = o->output;
|
||||||
|
ctx.hw_device_type = av_hwdevice_find_type_by_name(argv[2]);
|
||||||
|
ctx.hardware_device = argv[3];
|
||||||
|
|
||||||
|
ctx.encoder_name = argv[4];
|
||||||
|
ctx.software_format = av_get_pix_fmt(argv[5]);
|
||||||
|
ctx.out_bitrate = strtof(argv[6], NULL);
|
||||||
|
ctx.out_filename = argv[7];
|
||||||
|
|
||||||
ctx.encoder_name = "libx264";
|
|
||||||
ctx.software_format = av_get_pix_fmt("nv12");
|
|
||||||
av_dict_set(&ctx.encoder_opts, "preset", "veryfast", 0);
|
av_dict_set(&ctx.encoder_opts, "preset", "veryfast", 0);
|
||||||
|
|
||||||
ctx.out_filename = "dmabuf_recording_01.mkv";
|
|
||||||
ctx.out_bitrate = 29.2f; /* Mbps */
|
|
||||||
|
|
||||||
err = main_loop(&ctx);
|
err = main_loop(&ctx);
|
||||||
if (err)
|
if (err)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
Loading…
Reference in a new issue