[FFmpeg-devel] [PATCH] lavfi: add drawgraph filter

Paul B Mahol onemda at gmail.com
Mon Jun 29 11:02:55 CEST 2015


On 6/28/15, Paul B Mahol <onemda at gmail.com> wrote:
> On 6/28/15, Dave Rice <dave at dericed.com> wrote:
>>
>>> On Jun 28, 2015, at 1:54 PM, Paul B Mahol <onemda at gmail.com> wrote:
>>>
>>> On 6/28/15, Dave Rice <dave at dericed.com> wrote:
>>>>
>>>>> On Jun 28, 2015, at 11:07 AM, Paul B Mahol <onemda at gmail.com> wrote:
>>>>>
>>>>> On 6/28/15, Dave Rice <dave at dericed.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>>> On Jun 27, 2015, at 4:52 PM, Paul B Mahol <onemda at gmail.com> wrote:
>>>>>>>
>>>>>>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>>>>>>> ---
>>>>>>> doc/filters.texi           |  76 ++++++++++++
>>>>>>> libavfilter/Makefile       |   1 +
>>>>>>> libavfilter/allfilters.c   |   1 +
>>>>>>> libavfilter/vf_drawgraph.c | 297
>>>>>>> +++++++++++++++++++++++++++++++++++++++++++++
>>>>>>> 4 files changed, 375 insertions(+)
>>>>>>> create mode 100644 libavfilter/vf_drawgraph.c
>>>>>>>
>>>>>
>>>>> [...]
>>>>>
>>>>>>
>>>>>> With this version using a color name for foreground no longer works:
>>>>>>
>>>>>> This works:
>>>>>> ffplay -f lavfi -i mandelbrot -vf
>>>>>> signalstats,drawgraph=metadata=lavfi.signalstats.YAVG:min=0:max=255:slide=scroll:bg=green:fg=0x0000FF
>>>>>>
>>>>>> This doesn't:
>>>>>> ffplay -f lavfi -i mandelbrot -vf
>>>>>> signalstats,drawgraph=metadata=lavfi.signalstats.YAVG:min=0:max=255:slide=scroll:bg=green:fg=red
>>>>>
>>>>> AFAIK The expressions can not work with strings.
>>>>>
>>>>>>
>>>>>> Also here's an example with blend:
>>>>>> ffplay -f lavfi -i mandelbrot -vf "signalstats,split=3[a][b][c];\
>>>>>> [a]drawgraph=metadata=lavfi.signalstats.YAVG:min=0:max=255:slide=scroll:fg=0xFFFF0000:mode=dot[a1];\
>>>>>> [b]drawgraph=metadata=lavfi.signalstats.UAVG:min=0:max=255:slide=scroll:fg=0xFF00FF00:mode=dot[b1];\
>>>>>> [c]drawgraph=metadata=lavfi.signalstats.VAVG:min=0:max=255:slide=scroll:fg=0xFFFFFF00:mode=dot[c1];\
>>>>>> [a1][b1]blend=and[ab];[ab][c1]blend=and[out]"
>>>>>>
>>>>>
>>>>> The blending kills difference in colors so I may add multiple graphs
>>>>> support for filter.
>>>>
>>>> Setting the background to black and blending seems a little better,
>>>> though
>>>> I'm losing one of my graphs in this example.
>>>>
>>>> ./ffplay -f lavfi -i mandelbrot -vf "signalstats,split=3[a][b][c];\
>>>> [a]drawgraph=lavfi.signalstats.YAVG:min=0:max=255:slide=scroll:bg=black:fg=0x0000FF:mode=dot[a1];\
>>>> [b]drawgraph=lavfi.signalstats.YLOW:min=0:max=255:slide=scroll:bg=black:fg=0x00FF00:mode=dot[b1];\
>>>> [c]drawgraph=lavfi.signalstats.YHIGH:min=0:max=255:slide=scroll:bg=black:fg=0xFF0000:mode=dot[c1];\
>>>> [a1][b1]blend=lighten,[c1]blend=lighten[out]"
>>>>
>>>> Also the foreground expression is in ABGR or BGR.  This is the opposite
>>>> arrangement of what is specified here
>>>> http://ffmpeg.org/ffmpeg-utils.html#Color.
>>>
>>> Using blend for this is SLOW.
>>
>> If the background could set to full alpha, then multiple graphs could be
>> added together with the overlay filter. I tested some alpha expressions
>> with
>> bg (black at 00, 0x00000000) and didn't seem to get transparent results.
>
> Because filter use gbrp without alpha as output format. Will change it.
> Plan is use RGBA or even YUVA as final output.

Now it uses more friendly RGBA mode.

>
>>
>>> Have you tried new 'line' mode?
>>
>> Oooo, this is great. Probably more readable than dot in many situations.
>>
>>> Also expressions allow changing color of dot/line/bar so try it and
>>> tell me if its fine.
>>
>> I tested this with several modes and it works as expected (excepting that
>> ABGR/BGR vs RGBA/RGB note). Thanks for adding this.
>>
>> Some other comments:
>> I tried to use an equation within metadata but got no plotted result. For
>> instance, "metadata=pow(lavfi.signalstats.YMIN\,2)". There are some
>> values
>> that may occur in a wide range, so a logarithmic or mathematically
>> adjusted
>> display may be preferable.
>
> Will see what can be done.

This complicates filter a lot, and I think this is more suited for
another filter
which will just operate on metadata values.

>
>>
>> Can input width and input height be used in variables within a size
>> expression. In many cases I would like to draw the graph over the input
>> video, but to do this I must know the input video size in advance.
>
> I do not understand what you want. You want to be able to set size of
> filter to input video?

This again complicates filter and disallows using WxH notation and
named notations.


More information about the ffmpeg-devel mailing list