[FFmpeg-devel] [PATCH 1/2] libavfilter/scale: More descriptive in/ref/out logging

Kevin Mark kmark937 at gmail.com
Tue Jun 6 23:17:04 EEST 2017


On Tue, Jun 6, 2017 at 11:49 AM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> yes but its much harder to grep for as its not a single line anymore

I agree that it's not going to be as pretty a regular expression to
grep through, as there is 33% more data, but it should still be doable
without too much effort. How important is it that we maintain "API"
compatibility on verbose CLI output?

ffmpeg [...] scale2ref=0:0 [...] -v verbose - 2>&1 >/dev/null | grep -oP 'regex'

Where regex is:

(in|out|ref) +w:(\d+) h:(\d+) fmt:(\w+) sar:(\d+)\/(\d+)(?:
flags:0x[[:xdigit:]]+)?

Assuming GNU grep 2.25+, you'll get:

in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:640 h:360 fmt:rgb24 sar:3/4 flags:0x2

It also works with BSD grep 2.5.1-FreeBSD included in macOS if you use
the -E option instead of -P. These would be considered three separate
matches so if you're using a good regex engine it'd be pretty easy to
loop over each match, check the first group to determine if it's in,
ref, or out and act accordingly on the rest of the captured data. You
could also, if you wanted, assume that the first line is in and the
second line is out if you only have two matches (or lines even) and if
you have three matches/lines the first is in, second is ref, third is
out. If you needed it to work with less sophisticated engines it
shouldn't be too hard to dumb down the regex above.

Live-ish example: https://regex101.com/r/wvHLpa/1

Is there a special property that makes single lines much easier to
grep? Something specific to bash? I wouldn't think bash would have any
problems looping over this by line.

Thanks,
Kevin


More information about the ffmpeg-devel mailing list