Opened 4 months ago

Last modified 4 months ago

#8786 reopened defect

af_loudnorm: FINAL_FRAME handling does not update loudness anymore

Reported by: slomo Owned by:
Priority: normal Component: avfilter
Version: unspecified Keywords: loudnorm
Cc: k@ylo.ph Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

At the last frame there will be up to 3s of samples left in the buffer. These are currently copied out into a new AVFrame and then handled specially. While they were all already passed to the input EBUR128 context and the corresponding gain adjustments for them were stored in the deltas array in the previous INNER_FRAME processing, the whole last frame in the FINAL_FRAME handling is using the same index into that array.

Currently the last 30 gain adjustments stored in the deltas array are not used at all

In theory every 100ms (i.e. up to 30 times) the index into the deltas array would have to be incremented in the FINAL_FRAME handling, and like in the INNER_FRAME handling it would make sense to do linear interpolation between the current/next gain.

I've found this while porting the filter to Rust for a GStreamer plugin, the code of which can be found here: ​https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/blob/master/audio/audiofx/src/audioloudnorm.rs . This also contains lots of code comments for all the steps, which might be helpful to take over to the ffmpeg code too.

My solution for this might not be the best or most simple approach, but during my testing they worked so feel free to adapt them for the ffmpeg code.

You can find the solution for this issue here: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/blob/1730de6cea10cb73ff1ab882a8235d540bfa5061/audio/audiofx/src/audioloudnorm.rs#L735

If you agree that the above approach (incrementing the index every 100ms and linear interpolation as for INNER_FRAME) is the right thing to do here, I can also prepare a patch for the C code in ffmpeg.

Change History (4)

comment:1 Changed 4 months ago by cehoyos

Please provide the command line you tested together with the complete, uncut console output to make this a valid ticket or send your patch - made with git format-patch to the FFmpeg development mailing list, there is no patch discussion on this bug tracker.

comment:2 Changed 4 months ago by slomo

There is no patch, at this point this is a bug report. I can prepare a patch if this if you consider this a bug and my proposed solution is acceptable, or someone else can fix it.

comment:3 Changed 4 months ago by cehoyos

  • Resolution set to needs_more_info
  • Status changed from new to closed

Please feel free to reopen this bug report if you can provide the missing information, a patch sent to the FFmpeg development mailing list is much more appreciated though.

comment:4 Changed 4 months ago by richardpl

  • Resolution needs_more_info deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.