mltframework / mlt

MLT Multimedia Framework
https://www.mltframework.org
GNU Lesser General Public License v2.1
1.48k stars 313 forks source link

Problem with loudness-filter #613

Open Beiri22 opened 3 years ago

Beiri22 commented 3 years ago

I am rendering a kdenlive-project that uses the 2-pass loudness-filter. I did all the analysis steps so that the mlt-file contains the analysis result. But when running melt, I get hundrets of those error messages:

[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462
[filter loudness] Unable to load results: L: -26.002723 R: 3.046467     P 0.377462

I have looked up the filter source and found a sscanf-directive. As far as I understand, the input should match, but it obviously doesn't.

<entry producer="producer24" in="00:00:00.000" out="00:00:58.733">
   <property name="kdenlive:id">3</property>
   <property name="kdenlive:activeeffect">0</property>
   <filter id="filter23">
    <property name="program">-23</property>
    <property name="mlt_service">loudness</property>
    <property name="kdenlive_id">loudness</property>
    <property name="kdenlive:collapsed">0</property>
    <property name="results">L: -26.002723  R: 3.046467 P 0.377462</property>
   </filter>
  </entry>

Name : kdenlive Version : 20.08.2-1

Name : mlt Version : 6.22.1-4

ddennedy commented 3 years ago

The scanf does match the snprintf in the source code. Maybe the problem is that your MLT environment is expecting comma for the decimal separator, and the data is using periods. I read that Kdenlive is having some trouble with their change to try to switch the project file to be numeric locale agnostic. What does the first line <mlt ...> of the MLT XML say? I will add that it is working fine for me in Shotcut 20.09 with the filter "Normalize: Two Pass".

bmatherly commented 3 years ago

Locale mismatch is also my first suspicion.

ddennedy commented 3 years ago

But when running melt

How are you doing that? Command line manually? melt reads the locale and applies it. So, you may need to run with LC_NUMERIC=C melt ...

Beiri22 commented 3 years ago

The first line reads: <mlt LC_NUMERIC="C" producer="main_bin" version="6.22.1" root="...">

My system locale is set to de_DE.UTF_8

Adding the "LC_NUMERIC=C" to the command line works; But why does melt not use the locale setting of the "first line" when available?

ddennedy commented 3 years ago

MLT is modular such that melt does know anything about XML; only the dynamically-loaded xml module does. Since melt does much more than process XML it loads the system locale early to support numeric locale for command line options. The mlt_properties API in conjunction with the XML module normally does support the locale specified in the XML. However, this filter is using a formatted string and doing its own numeric parsing outside the mlt_properties API.

  1. One way to fix this to change melt to not setlocale() by default and add a command line option to do it for backwards compatibility. Now that both Shotcut and Kdenlive are using MLT and melt in a locale agnostic manner this seems likely to happen soon.
  2. Another way that would be nice is to use sscanf_l() to parse this string, but that is not available in glibc, and the code would have to repeat the ugly platform-specific patterns seen in mlt_properties.c and mlt_property.c.
  3. Another way is to apply the workaround pattern of temporarily switching locale as seen in filter_avformat.c for the lut3d filter.
sandsmark commented 3 years ago

another (huge) hack is to just check LC_NUMERIC and replace all instances of , with .. :-)

probably going to break other stuff, though.

ddennedy commented 3 years ago

MLT v7 will have the option to build with locale, which leads to point 1. The option will likely default to without locale, and only offer on as a deprecated legacy option with a bug like this unaddressed.