#10740: aspectralstats returns wrong centroid value
-------------------------------------+-------------------------------------
             Reporter:  penguin101   |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 **Summary of the bug:**

 I was running aspectralstats on a file with multiple audio channels. At
 the beginning of the file, there is only silence so the audio channels
 returned lavfi.aspectralstats.1.centroid=1, apart two of them that
 returned lavfi.aspectralstats.1.centroid=11924.6.

 I removed options and channels one by one till I arrived to the minimum to
 reproduce.


 **How to reproduce:**

 ffmpeg -v 9 -loglevel 99 -t 1 -i /Users/penguin/Downloads/wav_only.wav
 -filter_complex
 "aspectralstats=win_size=65536:overlap=0:win_func=welch,ametadata=print:file=-"
 -f null -

 ffmpeg version 6.1 Copyright (c) 2000-2023 the FFmpeg developers
   built with Apple clang version 15.0.0 (clang-1500.0.40.1)
   configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1-with-options_3
 --enable-shared --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic'
 --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame
 --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis
 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig
 --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash
 --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon
 --disable-htmlpages --enable-libfdk-aac --enable-nonfree
   libavutil      58. 29.100 / 58. 29.100
   libavcodec     60. 31.102 / 60. 31.102
   libavformat    60. 16.100 / 60. 16.100
   libavdevice    60.  3.100 / 60.  3.100
   libavfilter     9. 12.100 /  9. 12.100
   libswscale      7.  5.100 /  7.  5.100
   libswresample   4. 12.100 /  4. 12.100
   libpostproc    57.  3.100 / 57.  3.100
 Splitting the commandline.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument '9'.
 Reading option '-loglevel' ... matched as option 'loglevel' (set logging
 level) with argument '99'.
 Reading option '-t' ... matched as option 't' (record or transcode
 "duration" seconds of audio/video) with argument '1'.
 Reading option '-i' ... matched as output url with argument
 '/Users/penguin/Downloads/wav_only.wav'.
 Reading option '-filter_complex' ... matched as option 'filter_complex'
 (create a complex filtergraph) with argument
 
'aspectralstats=win_size=65536:overlap=0:win_func=welch,ametadata=print:file=-'.
 Reading option '-f' ... matched as option 'f' (force format) with argument
 'null'.
 Reading option '-' ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument 9.
 Applying option filter_complex (create a complex filtergraph) with
 argument
 aspectralstats=win_size=65536:overlap=0:win_func=welch,ametadata=print:file=-.
 [AVFilterGraph @ 0x14361a130] Setting 'win_size' to value '65536'
 [AVFilterGraph @ 0x14361a130] Setting 'overlap' to value '0'
 [AVFilterGraph @ 0x14361a130] Setting 'win_func' to value 'welch'
 [AVFilterGraph @ 0x14361a130] Setting 'mode' to value 'print'
 [AVFilterGraph @ 0x14361a130] Setting 'file' to value '-'
 [pipe @ 0x14361a650] Setting default whitelist 'crypto,data'
 [AVIOContext @ 0x14361a7d0] Statistics: 0 bytes written, 0 seeks, 0
 writeouts
 Successfully parsed a group of options.
 Parsing a group of options: input url
 /Users/penguin/Downloads/wav_only.wav.
 Applying option t (record or transcode "duration" seconds of audio/video)
 with argument 1.
 Successfully parsed a group of options.
 Opening an input file: /Users/penguin/Downloads/wav_only.wav.
 [AVFormatContext @ 0x14361a270] Opening
 '/Users/penguin/Downloads/wav_only.wav' for reading
 [file @ 0x14361a9b0] Setting default whitelist 'file,crypto,data'
 Probing wav score:99 size:2048
 [wav @ 0x14361a270] Format wav probed with size=2048 and score=99
 [wav @ 0x14361a270] Before avformat_find_stream_info() pos: 98 bytes
 read:65634 seeks:1 nb_streams:1
 [wav @ 0x14361a270] probing stream 0 pp:32
 [wav @ 0x14361a270] probing stream 0 pp:31
 [wav @ 0x14361a270] probing stream 0 pp:30
 [wav @ 0x14361a270] probing stream 0 pp:29
 [wav @ 0x14361a270] probing stream 0 pp:28
 [wav @ 0x14361a270] probing stream 0 pp:27
 [wav @ 0x14361a270] probing stream 0 pp:26
 [wav @ 0x14361a270] probing stream 0 pp:25
 [wav @ 0x14361a270] probing stream 0 pp:24
 [wav @ 0x14361a270] probing stream 0 pp:23
 [wav @ 0x14361a270] probing stream 0 pp:22
 [wav @ 0x14361a270] probing stream 0 pp:21
 [wav @ 0x14361a270] probing stream 0 pp:20
 [wav @ 0x14361a270] probing stream 0 pp:19
 [wav @ 0x14361a270] probing stream 0 pp:18
 [wav @ 0x14361a270] probing stream 0 pp:17
 [wav @ 0x14361a270] probing stream 0 pp:16
 [wav @ 0x14361a270] probing stream 0 pp:15
 [wav @ 0x14361a270] probing stream 0 pp:14
 [wav @ 0x14361a270] probing stream 0 pp:13
 [wav @ 0x14361a270] probing stream 0 pp:12
 [wav @ 0x14361a270] probing stream 0 pp:11
 [wav @ 0x14361a270] probing stream 0 pp:10
 [wav @ 0x14361a270] probing stream 0 pp:9
 [wav @ 0x14361a270] probing stream 0 pp:8
 [wav @ 0x14361a270] probing stream 0 pp:7
 [wav @ 0x14361a270] probing stream 0 pp:6
 [wav @ 0x14361a270] probing stream 0 pp:5
 [wav @ 0x14361a270] probing stream 0 pp:4
 [wav @ 0x14361a270] probing stream 0 pp:3
 [wav @ 0x14361a270] probing stream 0 pp:2
 [wav @ 0x14361a270] probing stream 0 pp:1
 [wav @ 0x14361a270] probed stream 0
 [wav @ 0x14361a270] parser not found for codec pcm_s16le, packets or times
 may be invalid.
 [wav @ 0x14361a270] All info found
 [wav @ 0x14361a270] stream 0: start_time: NOPTS duration: 10
 [wav @ 0x14361a270] format: start_time: NOPTS duration: 10 (estimate from
 stream) bitrate=768 kb/s
 [wav @ 0x14361a270] After avformat_find_stream_info() pos: 204898 bytes
 read:295010 seeks:1 frames:50
 [aist#0:0/pcm_s16le @ 0x14361d560] Guessed Channel Layout: mono
 Input #0, wav, from '/Users/penguin/Downloads/wav_only.wav':
   Metadata:
     encoder         : Lavf60.16.100
     timecode        : 00:00:00:00
   Duration: 00:00:10.00, bitrate: 768 kb/s
   Stream #0:0, 50, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001),
 48000 Hz, 1 channels, s16, 768 kb/s
 Successfully opened the file.
 Parsing a group of options: output url -.
 Applying option f (force format) with argument null.
 Successfully parsed a group of options.
 Opening an output file: -.
 [out#0/null @ 0x144004090] Creating output stream from unlabeled output of
 complex filtergraph 0. This overrides automatic audio mapping.
 [aost#0:0/pcm_s16le @ 0x144004ca0] Created audio stream from complex
 filtergraph 0:[ametadata:default]
 [aost#0:0/pcm_s16le @ 0x144004ca0]
 [out#0/null @ 0x144004090] No explicit maps, mapping streams
 automatically...
 Successfully opened the file.
 Stream mapping:
   Stream #0:0 (pcm_s16le) -> aspectralstats:default
   ametadata:default -> Stream #0:0 (pcm_s16le)
 Press [q] to stop, [?] for help
 [AVFilterGraph @ 0x143704e60] Setting 'win_size' to value '65536'
 [AVFilterGraph @ 0x143704e60] Setting 'overlap' to value '0'
 [AVFilterGraph @ 0x143704e60] Setting 'win_func' to value 'welch'
 [AVFilterGraph @ 0x143704e60] Setting 'mode' to value 'print'
 [AVFilterGraph @ 0x143704e60] Setting 'file' to value '-'
 detected 10 logical cores
 [pipe @ 0x143705210] Setting default whitelist 'crypto,data'
 [graph_0_in_0_0 @ 0x143705a80] Setting 'time_base' to value '1/48000'
 [graph_0_in_0_0 @ 0x143705a80] Setting 'sample_rate' to value '48000'
 [graph_0_in_0_0 @ 0x143705a80] Setting 'sample_fmt' to value 's16'
 [graph_0_in_0_0 @ 0x143705a80] Setting 'channel_layout' to value 'mono'
 [graph_0_in_0_0 @ 0x143705a80] tb:1/48000 samplefmt:s16 samplerate:48000
 chlayout:mono
 [format_out_0_0 @ 0x143706100] Setting 'sample_fmts' to value 's16'
 [trim for input stream 0:0 @ 0x143705b30] auto-inserting filter
 'auto_aresample_0' between the filter 'graph_0_in_0_0' and the filter
 'trim for input stream 0:0'
 [format_out_0_0 @ 0x143706100] auto-inserting filter 'auto_aresample_1'
 between the filter 'Parsed_ametadata_1' and the filter 'format_out_0_0'
 [AVFilterGraph @ 0x143704e60] query_formats: 6 queried, 6 merged, 11
 already done, 0 delayed
 [auto_aresample_0 @ 0x143706a10] [SWR @ 0x138008000] Using s16p internally
 between filters
 [auto_aresample_0 @ 0x143706a10] ch:1 chl:mono fmt:s16 r:48000Hz -> ch:1
 chl:mono fmt:fltp r:48000Hz
 For transform of length 65536, forward, fft_float, flags: [aligned,
 out_of_place], found 6 matches:
     1: fft_sr_float_neon - type: fft_float, len: [64, 131072], factor: 2,
 flags: [aligned, out_of_place], prio: 224
     2: fft_pfa_float_c - type: fft_float, len: [6, ∞], factors[2]: [7, 5,
 3, 2, any], flags: [unaligned, inplace, out_of_place], prio: 112
     3: fft_float_c - type: fft_float, len: [2, ∞], factor: -1, flags:
 [unaligned, out_of_place], prio: 0
     4: fft_inplace_small_float_c - type: fft_float, len: [2, 65536],
 factor: -1, flags: [unaligned, inplace, out_of_place], prio: -256
     5: fft_inplace_float_c - type: fft_float, len: [2, ∞], factor: -1,
 flags: [unaligned, inplace, out_of_place], prio: -512
     6: fft_naive_float_c - type: fft_float, len: [2, ∞], factor: -1,
 flags: [unaligned, out_of_place], prio: -131072
 Transform tree:
     fft_sr_float_neon - type: fft_float, len: 65536, factor: 2, flags:
 [aligned, out_of_place]
 [auto_aresample_1 @ 0x143706d60] [SWR @ 0x138020000] Using fltp internally
 between filters
 [auto_aresample_1 @ 0x143706d60] ch:1 chl:mono fmt:fltp r:48000Hz -> ch:1
 chl:mono fmt:s16 r:48000Hz
 Output #0, null, to 'pipe:':
   Metadata:
     timecode        : 00:00:00:00
     encoder         : Lavf60.16.100
   Stream #0:0, 0, 1/48000: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
     Metadata:
       encoder         : Lavc60.31.102 pcm_s16le
 [out_0_0 @ 0x143705fa0] EOF on sink link out_0_0:default.
 No more output streams to write to, finishing.
 [aist#0:0/pcm_s16le @ 0x14361d560] Decoder thread received EOF packet
 [aist#0:0/pcm_s16le @ 0x14361d560] Decoder returned EOF, finishing
 [aist#0:0/pcm_s16le @ 0x14361d560] Terminating decoder thread
 [out#0/null @ 0x144004090] All streams finished
 [out#0/null @ 0x144004090] Terminating muxer thread
 [out#0/null @ 0x144004090] Output file #0 (pipe:):
 [out#0/null @ 0x144004090]   Output stream #0:0 (audio): 1 frames encoded
 (48000 samples); 1 packets muxed (96000 bytes);
 [out#0/null @ 0x144004090]   Total: 1 packets (96000 bytes) muxed
 [out#0/null @ 0x144004090] video:0kB audio:94kB subtitle:0kB other
 streams:0kB global headers:0kB muxing overhead: unknown
 size=N/A time=00:00:00.00 bitrate=N/A speed=   0x
 frame:0    pts:0       pts_time:0
 lavfi.aspectralstats.1.mean=2.38036e-08
 lavfi.aspectralstats.1.variance=3.11499e-16
 lavfi.aspectralstats.1.centroid=11924.6
 lavfi.aspectralstats.1.spread=6956.26
 lavfi.aspectralstats.1.skewness=0.000764508
 lavfi.aspectralstats.1.kurtosis=1.80617
 lavfi.aspectralstats.1.entropy=0.00117855
 lavfi.aspectralstats.1.flatness=0.99579
 lavfi.aspectralstats.1.crest=0
 lavfi.aspectralstats.1.flux=5.36412e-06
 lavfi.aspectralstats.1.slope=-4.46234e-10
 lavfi.aspectralstats.1.decrease=-0.0270039
 lavfi.aspectralstats.1.rolloff=20398.7
 [AVIOContext @ 0x143705790] Statistics: 557 bytes written, 0 seeks, 1
 writeouts
 [in#0/wav @ 0x14361a7d0] Terminating demuxer thread
 [in#0/wav @ 0x14361a7d0] Input file #0
 (/Users/penguin/Downloads/wav_only.wav):
 [in#0/wav @ 0x14361a7d0]   Input stream #0:0 (audio): 27 packets read
 (110592 bytes); 25 frames decoded; 0 decode errors (51200 samples);
 [in#0/wav @ 0x14361a7d0]   Total: 27 packets (110592 bytes) demuxed
 [AVIOContext @ 0x14361a520] Statistics: 295010 bytes read, 1 seeks
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10740>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac

To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to