2018-09-13 17:52 GMT+02:00, alan.birt...@sony.com<mailto:alan.birt...@sony.com> <alan.birt...@sony.com<mailto:alan.birt...@sony.com>>:
> I've developed a patch to add an option to allow cropping of the > avfoundation screen capture. > Note that if the captured width is not a multiple of 16 then > https://urldefense.proofpoint.com/v2/url?u=https-3A__trac.ffmpeg.org_ticket_5654&d=DwIGaQ&c=fP4tf--1dS0biCFlB0saz0I0kjO5v7-GLPtvShAo4cc&r=DZ-pOCz_nOIJfdxhe1zNBFwbfB1WJzA5E9fM05n7yCs&m=KjmPPiSi2W239ebqa6B1xWjvn3F0kSW7fSlmVx4n70s&s=1a0Z8KLo3pYG0TjLl0zZzlF3E68mO58ssmKjXnW9yYg&e= > will be triggered. Resending patch as Outlook got the mime-type of the original incorrect.
From 96b9cd33022bb6f3147174085c9ff2417cd006bc Mon Sep 17 00:00:00 2001 From: Alan Birtles <alan.birt...@eu.sony.com> Date: Thu, 13 Sep 2018 15:56:55 +0100 Subject: [PATCH] allow specifying "cropRect" for avfoundation screen capture --- libavdevice/avfoundation.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m index fc6428a..c285984 100644 --- a/libavdevice/avfoundation.m +++ b/libavdevice/avfoundation.m @@ -97,6 +97,10 @@ int capture_cursor; int capture_mouse_clicks; + int capture_crop_x; + int capture_crop_y; + int capture_crop_width; + int capture_crop_height; int list_devices; int video_device_index; @@ -750,6 +754,13 @@ static int avf_read_header(AVFormatContext *s) capture_screen_input.capturesMouseClicks = NO; } + if (ctx->capture_crop_x != 0 || + ctx->capture_crop_y != 0 || + ctx->capture_crop_width != 0 || + ctx->capture_crop_height != 0) { + capture_screen_input.cropRect = CGRectMake(ctx->capture_crop_x, ctx->capture_crop_y, ctx->capture_crop_width, ctx->capture_crop_height); + } + video_device = (AVCaptureDevice*) capture_screen_input; capture_screen = 1; #endif @@ -799,6 +810,13 @@ static int avf_read_header(AVFormatContext *s) } else { capture_screen_input.capturesMouseClicks = NO; } + + if (ctx->capture_crop_x != 0 || + ctx->capture_crop_y != 0 || + ctx->capture_crop_width != 0 || + ctx->capture_crop_height != 0) { + capture_screen_input.cropRect = CGRectMake(ctx->capture_crop_x, ctx->capture_crop_y, ctx->capture_crop_width, ctx->capture_crop_height); + } } } #endif @@ -1069,6 +1087,9 @@ static int avf_close(AVFormatContext *s) { "video_size", "set video size", offsetof(AVFContext, width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { "capture_mouse_clicks", "capture the screen mouse clicks", offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { "capture_crop_x", "crop the screen capture to the specified x offset", offsetof(AVFContext, capture_crop_x), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "capture_crop_y", "crop the screen capture to the specified y offset", offsetof(AVFContext, capture_crop_y), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "capture_crop_size", "crop the screen capture to the specified size", offsetof(AVFContext, capture_crop_width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; -- 2.15.1 (Apple Git-101)
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel