[FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter
Daniel Molkentin
daniel at molkentin.de
Sun Oct 7 19:02:29 EEST 2018
This allows switching between absolute (LUFS) and relativ (LU) display
in the status line.
Signed-off-by: Daniel Molkentin <daniel at molkentin.de>
Signed-off-by: Conrad Zelck <c.zelck at 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).
+
+ at 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) { \
--
2.17.1
More information about the ffmpeg-devel
mailing list