diff mbox

[FFmpeg-devel] avdevice/avfoundation: add scaleFactor attribute for avfoundation

Message ID 1501515291-95794-1-git-send-email-sharpbai@gmail.com
State Superseded
Headers show

Commit Message

sharpbai July 31, 2017, 3:34 p.m. UTC
From: sharpbai <tian.bai@duobei.com>

feature: add scaleFactor attribute for avfoundation
added by: siyuan.wang@duobei.com
added by: yiren.li@duobei.com
---
 doc/indevs.texi            | 6 ++++++
 libavdevice/avfoundation.m | 8 ++++++++
 2 files changed, 14 insertions(+)

Comments

Thilo Borgmann July 31, 2017, 8:33 p.m. UTC | #1
Am 31.07.17 um 17:34 schrieb sharpbai:
> From: sharpbai <tian.bai@duobei.com>
> 
> feature: add scaleFactor attribute for avfoundation
> added by: siyuan.wang@duobei.com
> added by: yiren.li@duobei.com
> ---
>  doc/indevs.texi            | 6 ++++++
>  libavdevice/avfoundation.m | 8 ++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index 09e3321..3d25930 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
>  @item -capture_mouse_clicks
>  Capture the screen mouse clicks. Default is 0.
>  
> +@item -scale_factor
> +Scale factor for capture the screen. Set this property to scale the buffers
> +by a given factor. For example a 320x240 capture area with a scale_factor of 2.0
> +produces video buffers at 640x480. Another example a 320x240 capture area with
> +a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0 (no scaling).
> +

Copy & Paste from the Apple's reference is hardly what is expected, please find your own wording.
Adding an example would be nice.
Maybe even renaming the option or state more implicitly that this option is for screen recording only.

How does it work? 

At least for me, this
"ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.5 -i "" out.avi" 
produces the same output resolution and viewport like that
"ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.0 -i "" out.avi".
What am I missing?
Some previous questions remain, about factor > 2.0 and factor < 1.0?


>  @end table
>  
>  @subsection Examples
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index e2ddf47..3764de8 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -96,6 +96,7 @@ typedef struct
>  
>      int             capture_cursor;
>      int             capture_mouse_clicks;
> +    float           scale_factor;
>  
>      int             list_devices;
>      int             video_device_index;
> @@ -735,6 +736,12 @@ static int avf_read_header(AVFormatContext *s)
>                  capture_screen_input.minFrameDuration = CMTimeMake(ctx->framerate.den, ctx->framerate.num);
>              }
>  
> +            if (ctx->scale_factor <= 2.0 && ctx->scale_factor > 0.0) {
> +                capture_screen_input.scaleFactor = ctx->scale_factor;
> +            } else {
> +                av_log(ctx, AV_LOG_ERROR, "The value of scale_factor must be more than 0.0 and less than or equal to 2.0");
> +            }
> +

I'm quite sure this is not what was meant to be checked.
Also, the range of this option is already guarded when reading it from the command line, you don't have to take care about out of limits here.



>  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
>              if (ctx->capture_cursor) {
>                  capture_screen_input.capturesCursor = YES;
> @@ -1025,6 +1032,7 @@ static const AVOption options[] = {
>      { "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 },
> +    { "scale_factor", "scale screen factor range", offsetof(AVFContext, scale_factor), 

It is not a range but the value (within a range) defining the scale factor of screen recording.
Also find something more precisely here, please.


> AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 2.0, AV_OPT_FLAG_DECODING_PARAM },
>  
>      { NULL },
>  };
> 

-Thilo
Saeid Zangeneh July 31, 2017, 8:47 p.m. UTC | #2
thanks
but i'm using linux ubuntu system.


On Tue, Aug 1, 2017 at 1:03 AM, Thilo Borgmann <thilo.borgmann@mail.de>
wrote:

> Am 31.07.17 um 17:34 schrieb sharpbai:
> > From: sharpbai <tian.bai@duobei.com>
> >
> > feature: add scaleFactor attribute for avfoundation
> > added by: siyuan.wang@duobei.com
> > added by: yiren.li@duobei.com
> > ---
> >  doc/indevs.texi            | 6 ++++++
> >  libavdevice/avfoundation.m | 8 ++++++++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/doc/indevs.texi b/doc/indevs.texi
> > index 09e3321..3d25930 100644
> > --- a/doc/indevs.texi
> > +++ b/doc/indevs.texi
> > @@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
> >  @item -capture_mouse_clicks
> >  Capture the screen mouse clicks. Default is 0.
> >
> > +@item -scale_factor
> > +Scale factor for capture the screen. Set this property to scale the
> buffers
> > +by a given factor. For example a 320x240 capture area with a
> scale_factor of 2.0
> > +produces video buffers at 640x480. Another example a 320x240 capture
> area with
> > +a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0
> (no scaling).
> > +
>
> Copy & Paste from the Apple's reference is hardly what is expected, please
> find your own wording.
> Adding an example would be nice.
> Maybe even renaming the option or state more implicitly that this option
> is for screen recording only.
>
> How does it work?
>
> At least for me, this
> "ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.5 -i ""
> out.avi"
> produces the same output resolution and viewport like that
> "ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.0 -i ""
> out.avi".
> What am I missing?
> Some previous questions remain, about factor > 2.0 and factor < 1.0?
>
>
> >  @end table
> >
> >  @subsection Examples
> > diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> > index e2ddf47..3764de8 100644
> > --- a/libavdevice/avfoundation.m
> > +++ b/libavdevice/avfoundation.m
> > @@ -96,6 +96,7 @@ typedef struct
> >
> >      int             capture_cursor;
> >      int             capture_mouse_clicks;
> > +    float           scale_factor;
> >
> >      int             list_devices;
> >      int             video_device_index;
> > @@ -735,6 +736,12 @@ static int avf_read_header(AVFormatContext *s)
> >                  capture_screen_input.minFrameDuration =
> CMTimeMake(ctx->framerate.den, ctx->framerate.num);
> >              }
> >
> > +            if (ctx->scale_factor <= 2.0 && ctx->scale_factor > 0.0) {
> > +                capture_screen_input.scaleFactor = ctx->scale_factor;
> > +            } else {
> > +                av_log(ctx, AV_LOG_ERROR, "The value of scale_factor
> must be more than 0.0 and less than or equal to 2.0");
> > +            }
> > +
>
> I'm quite sure this is not what was meant to be checked.
> Also, the range of this option is already guarded when reading it from the
> command line, you don't have to take care about out of limits here.
>
>
>
> >  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
> >              if (ctx->capture_cursor) {
> >                  capture_screen_input.capturesCursor = YES;
> > @@ -1025,6 +1032,7 @@ static const AVOption options[] = {
> >      { "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 },
> > +    { "scale_factor", "scale screen factor range", offsetof(AVFContext,
> scale_factor),
>
> It is not a range but the value (within a range) defining the scale factor
> of screen recording.
> Also find something more precisely here, please.
>
>
> > AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 2.0, AV_OPT_FLAG_DECODING_PARAM },
> >
> >      { NULL },
> >  };
> >
>
> -Thilo
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 09e3321..3d25930 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -139,6 +139,12 @@  Capture the mouse pointer. Default is 0.
 @item -capture_mouse_clicks
 Capture the screen mouse clicks. Default is 0.
 
+@item -scale_factor
+Scale factor for capture the screen. Set this property to scale the buffers
+by a given factor. For example a 320x240 capture area with a scale_factor of 2.0
+produces video buffers at 640x480. Another example a 320x240 capture area with
+a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0 (no scaling).
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e2ddf47..3764de8 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -96,6 +96,7 @@  typedef struct
 
     int             capture_cursor;
     int             capture_mouse_clicks;
+    float           scale_factor;
 
     int             list_devices;
     int             video_device_index;
@@ -735,6 +736,12 @@  static int avf_read_header(AVFormatContext *s)
                 capture_screen_input.minFrameDuration = CMTimeMake(ctx->framerate.den, ctx->framerate.num);
             }
 
+            if (ctx->scale_factor <= 2.0 && ctx->scale_factor > 0.0) {
+                capture_screen_input.scaleFactor = ctx->scale_factor;
+            } else {
+                av_log(ctx, AV_LOG_ERROR, "The value of scale_factor must be more than 0.0 and less than or equal to 2.0");
+            }
+
 #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
             if (ctx->capture_cursor) {
                 capture_screen_input.capturesCursor = YES;
@@ -1025,6 +1032,7 @@  static const AVOption options[] = {
     { "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 },
+    { "scale_factor", "scale screen factor range", offsetof(AVFContext, scale_factor), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 2.0, AV_OPT_FLAG_DECODING_PARAM },
 
     { NULL },
 };