Opened 2 years ago

Last modified 19 months ago

#9757 new enhancement

cropdetect ignores a value of 1 as the round parameter

Reported by: Llyw Owned by:
Priority: wish Component: avfilter
Version: git-master Keywords: cropdetect
Cc: Llyw Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Llyw)

In its current implementation, the cropdetect filter does not accept a value of 1 for the round parameter and falls back to the default value, which currently is 16.

While not explicitly documented in the online help, I assume that this is due to 2 being the minimum value for the round parameter. This unfortunately forces us to remove information even when this is not necessary: If I am rescaling the cropped image to output dimensions that satisfy all divisibility requirements enforced by the codec and sample format before encoding, the output of cropdetect does not even have to satisfy any divisibility requirements. (I do understand that one might have to specify exact=1 when using the crop filter in such a scenario.)

So I would appreciate it, if the lowest accepted value for round is changed to 1. (In the hopes that the code then does not modify the detected crop any further since all integer numbers are already divisible by 1.) Note that one should also properly document the minimum value for the round param.

Change History (7)

comment:1 by Llyw, 2 years ago

Cc: Llyw added

comment:2 by Llyw, 2 years ago

Description: modified (diff)

comment:3 by Llyw, 2 years ago

Description: modified (diff)

comment:4 by Llyw, 2 years ago

Description: modified (diff)

comment:5 by Llyw, 2 years ago

Description: modified (diff)

comment:6 by Llyw, 2 years ago

I just took a look at the source code and realized that there are even more restrictions in place that are not documented: In addition to the round parameter needing to be greater than 1, it will also automatically get multiplied by 2 if the input value is odd and the offsets for the crop rectangle are also modified such that they are divisible by 2.

While a comment in the code suggests that this has something to do with the YUV color model, the code more likely was added to ensure that one will obtain an output that works with chroma subsampled video.

However, again, such requirements would not have to be met in my use case (or when you are working with non-subsampled formats) and you can already tell the crop filter that you want it to be exact. But instead of a simple relaxation of the minimum value for round, it seems that I would need you to introduce a setting that would drop the aforementioned restrictions of the round parameter and modification of cropdetect's output altogether, just like exact=1 does for crop. Such a setting could be off by default to keep things backwards compatible.

Last edited 2 years ago by Llyw (previous) (diff)

comment:7 by Carl Eugen Hoyos, 19 months ago

Keywords: round removed
Priority: normalwish
Version: unspecifiedgit-master
Note: See TracTickets for help on using tickets.