[FFmpeg-devel,5/5] libavfilter/ebur128: add mabsolute parameter

Submitted by Daniel Molkentin on Oct. 7, 2018, 4:02 p.m.

Details

Message ID 20181007160229.18250-6-daniel@molkentin.de
State New
Headers show

Commit Message

Daniel Molkentin Oct. 7, 2018, 4:02 p.m.
This allows switching between absolute (LUFS) and relativ (LU) display
in the status line.

Signed-off-by: Daniel Molkentin <daniel@molkentin.de>
Signed-off-by: Conrad Zelck <c.zelck@imail.de>
---
 doc/filters.texi        |  4 ++++
 libavfilter/f_ebur128.c | 34 +++++++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 9 deletions(-)

Comments

Paul B Mahol Oct. 7, 2018, 7:33 p.m.
On 10/7/18, Daniel Molkentin <daniel@molkentin.de> wrote:
>
> On 07.10.2018 18:02, Daniel Molkentin wrote:
>> This allows switching between absolute (LUFS) and relativ (LU) display
>> in the status line.
>>
>> Signed-off-by: Daniel Molkentin <daniel@molkentin.de>
>> Signed-off-by: Conrad Zelck <c.zelck@imail.de>
>> ---
>>  doc/filters.texi        |  4 ++++
>>  libavfilter/f_ebur128.c | 34 +++++++++++++++++++++++++---------
>>  2 files changed, 29 insertions(+), 9 deletions(-)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 601cbda17c..dc01c805b2 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -19371,6 +19371,10 @@ by EBU R128. However, material published online
>> may prefer a level of -16LUFS
>>  Set the value displayed by the gauge. Valid values are m (momentary) and
>> s (short-term).
>>  By default the momentary value will be used, but in certain scenarios it
>> may be more useful
>>  to observe the short term value instead (e.g. live mixing).
>> +
>> +@item mabsolute
>> +Sets whether to display the loudness in LUFS (1, the default) LU relative
>> to the target (0).
>> +This only affects the video output, not the summary or continous log
>> output.
>>  @end table
>>
> On a second thought, should this maybe be measurement=absolute|relative
> or measurement=LU|LUFS? Opinions? More descriptive that way...

Yeah, that one is more descriptive, you also can have aliases so can have
both absolute/relative/LU/LUFS
Daniel Molkentin Oct. 7, 2018, 7:50 p.m.
On 07.10.2018 21:37, Marton Balint wrote:
>
>
> On Sun, 7 Oct 2018, Daniel Molkentin wrote:
>
>>
>> On 07.10.2018 18:02, Daniel Molkentin wrote:
>>> This allows switching between absolute (LUFS) and relativ (LU) display
>>> in the status line.
>>>
>>> Signed-off-by: Daniel Molkentin <daniel@molkentin.de>
>>> Signed-off-by: Conrad Zelck <c.zelck@imail.de>
>>> ---
>>>  doc/filters.texi        |  4 ++++
>>>  libavfilter/f_ebur128.c | 34 +++++++++++++++++++++++++---------
>>>  2 files changed, 29 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>> index 601cbda17c..dc01c805b2 100644
>>> --- a/doc/filters.texi
>>> +++ b/doc/filters.texi
>>> @@ -19371,6 +19371,10 @@ by EBU R128. However, material published
>>> online may prefer a level of -16LUFS
>>>  Set the value displayed by the gauge. Valid values are m
>>> (momentary) and s (short-term).
>>>  By default the momentary value will be used, but in certain
>>> scenarios it may be more useful
>>>  to observe the short term value instead (e.g. live mixing).
>>> +
>>> +@item mabsolute
>>> +Sets whether to display the loudness in LUFS (1, the default) LU
>>> relative to the target (0).
>>> +This only affects the video output, not the summary or continous
>>> log output.
>>>  @end table
>>>
>> On a second thought, should this maybe be measurement=absolute|relative
>> or measurement=LU|LUFS? Opinions? More descriptive that way...
>
> scale=absolute/relative
>
> IMHO that makes it the most descriptive.
We thought about that, but the first association we thought people might
have when confronted with the word scale are the histogram labels with
the LU values on the right, (which are untouched by this option). I am
fine with either.

Cheers,
  Daniel
Marton Balint Oct. 7, 2018, 9:17 p.m.
On Sun, 7 Oct 2018, Daniel Molkentin wrote:

>
> On 07.10.2018 21:37, Marton Balint wrote:
>>
>>
>> On Sun, 7 Oct 2018, Daniel Molkentin wrote:
>>
>>>
>>> On 07.10.2018 18:02, Daniel Molkentin wrote:
>>>> This allows switching between absolute (LUFS) and relativ (LU) display
>>>> in the status line.
>>>>
>>>> Signed-off-by: Daniel Molkentin <daniel@molkentin.de>
>>>> Signed-off-by: Conrad Zelck <c.zelck@imail.de>
>>>> ---
>>>>  doc/filters.texi        |  4 ++++
>>>>  libavfilter/f_ebur128.c | 34 +++++++++++++++++++++++++---------
>>>>  2 files changed, 29 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>>> index 601cbda17c..dc01c805b2 100644
>>>> --- a/doc/filters.texi
>>>> +++ b/doc/filters.texi
>>>> @@ -19371,6 +19371,10 @@ by EBU R128. However, material published
>>>> online may prefer a level of -16LUFS
>>>>  Set the value displayed by the gauge. Valid values are m
>>>> (momentary) and s (short-term).
>>>>  By default the momentary value will be used, but in certain
>>>> scenarios it may be more useful
>>>>  to observe the short term value instead (e.g. live mixing).
>>>> +
>>>> +@item mabsolute
>>>> +Sets whether to display the loudness in LUFS (1, the default) LU
>>>> relative to the target (0).
>>>> +This only affects the video output, not the summary or continous
>>>> log output.
>>>>  @end table
>>>>
>>> On a second thought, should this maybe be measurement=absolute|relative
>>> or measurement=LU|LUFS? Opinions? More descriptive that way...
>>
>> scale=absolute/relative
>>
>> IMHO that makes it the most descriptive.
> We thought about that, but the first association we thought people might
> have when confronted with the word scale are the histogram labels with
> the LU values on the right, (which are untouched by this option). I am
> fine with either.

Ah, OK, I kind of missed that it affects the status line. IMHO the status 
line is not very useful because the text is too small for anything 
serious, so I would not put too much effort into customizing it. I have a 
patch somewhere that adds the same metadata to the video which is already added 
to the audio, so one can use the drawtext filter to present customized 
text in as big as the user needs. I can dig it up if you are interested.

Regards,
Marton

Patch hide | download patch | download mbox

diff --git a/doc/filters.texi b/doc/filters.texi
index 601cbda17c..dc01c805b2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19371,6 +19371,10 @@  by EBU R128. However, material published online may prefer a level of -16LUFS
 Set the value displayed by the gauge. Valid values are m (momentary) and s (short-term).
 By default the momentary value will be used, but in certain scenarios it may be more useful
 to observe the short term value instead (e.g. live mixing).
+
+@item mabsolute
+Sets whether to display the loudness in LUFS (1, the default) LU relative to the target (0).
+This only affects the video output, not the summary or continous log output.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 182e0cbe98..5d58abc741 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -146,6 +146,7 @@  typedef struct EBUR128Context {
     double pan_law;                 ///< pan law value used to calculate dual-mono measurements
     int target;                     ///< target level in LUFS used to set relative zero LU in visualization
     char *gauge_type;               ///< whether gauge shows momentary or short
+    int mabsolute;                 ///< whether to display the statistics in LUFS or LU
 } EBUR128Context;
 
 enum {
@@ -174,6 +175,7 @@  static const AVOption ebur128_options[] = {
     { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
     { "target", "set a specific target level in LUFS (-23 to 0)", OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
     { "gaugetype", "sets whether the gauge shows momentrary (m) or short-term (s)", OFFSET(gauge_type), AV_OPT_TYPE_STRING, {.str = "m"}, CHAR_MIN, CHAR_MAX, V|F },
+    { "mabsolute", "sets whether the stats should be displayed absolute (LUFS, default) or relative (LU) ", OFFSET(mabsolute), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, V|F },
     { NULL },
 };
 
@@ -755,7 +757,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
                 loudness_3000 -= ebur128->pan_law;
             }
 
-#define LOG_FMT "TARGET:%d     M:%6.1f S:%6.1f     I:%6.1f LUFS     LRA:%6.1f LU"
+#define LOG_FMT "TARGET:%d LUFS    M:%6.1f S:%6.1f     I:%6.1f %s       LRA:%6.1f LU"
 
             /* push one video frame */
             if (ebur128->do_video) {
@@ -793,10 +795,17 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
                 }
 
                 /* draw textual info */
-                drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
-                         LOG_FMT "     ", // padding to erase trailing characters
-                         ebur128->target, loudness_400, loudness_3000,
-                         ebur128->integrated_loudness, ebur128->loudness_range);
+                if (ebur128->mabsolute) {
+                    drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
+                             LOG_FMT "     ", // padding to erase trailing characters
+                             ebur128->target, loudness_400, loudness_3000,
+                             ebur128->integrated_loudness, "LUFS", ebur128->loudness_range);
+                } else {
+                    drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
+                             LOG_FMT "     ", // padding to erase trailing characters
+                             ebur128->target, loudness_400-ebur128->target, loudness_3000-ebur128->target,
+                             ebur128->integrated_loudness-ebur128->target, "LU", ebur128->loudness_range);
+                }
 
                 /* set pts and push frame */
                 pic->pts = pts;
@@ -836,10 +845,17 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
                 SET_META_PEAK(true,   TRUE);
             }
 
-            av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
-                   av_ts2timestr(pts, &outlink->time_base),
-                   ebur128->target, loudness_400, loudness_3000,
-                   ebur128->integrated_loudness, ebur128->loudness_range);
+            if (ebur128->mabsolute) {
+                av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
+                       av_ts2timestr(pts, &outlink->time_base),
+                       ebur128->target, loudness_400, loudness_3000,
+                       ebur128->integrated_loudness, "LUFS", ebur128->loudness_range);
+            } else {
+                av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
+                       av_ts2timestr(pts, &outlink->time_base),
+                       ebur128->target, loudness_400-ebur128->target, loudness_3000-ebur128->target,
+                       ebur128->integrated_loudness-ebur128->target, "LU", ebur128->loudness_range);
+            }
 
 #define PRINT_PEAKS(str, sp, ptype) do {                            \
     if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) {       \