Opened 3 weeks ago

Last modified 7 days ago

#11281 new defect

"showwavespic" failed for "Too few samples"?

Reported by: Danny Weijermans Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: showwavespic
Cc: MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

ffmpeg is great for creating waveform overviews.
however, it doesn't work with very short - < 200msec - soundfiles.
could this be fixed?

Attachments (6)

s.wav (6.0 KB ) - added by Danny Weijermans 3 weeks ago.
very short <200ms wav soundfile
t.wav (7.3 KB ) - added by Danny Weijermans 3 weeks ago.
a very short <200ms wav STEREO soundfile 24bits
FL.wav (6.0 KB ) - added by Danny Weijermans 2 weeks ago.
short soundfile with recognizable waveform
FLffmpeg.png (857 bytes ) - added by Danny Weijermans 2 weeks ago.
ffmpeg showwavespic result: samples are truncated on the right side (or: not enough samples are shown)
FLright.png (600.4 KB ) - added by Danny Weijermans 2 weeks ago.
how the fl.wav should really look as a waveform
FL.webp (222.3 KB ) - added by MasterQuestionable 2 weeks ago.
[[Image(...)]]

Download all attachments as: .zip

Change History (28)

comment:1 by MasterQuestionable, 3 weeks ago

Cc: MasterQuestionable added
Keywords: audio added; ffmpeg soundfiles removed

͏    Probably relevant:
͏    https://trac.ffmpeg.org/ticket/11018#comment:2

͏    What's the command line?

by Danny Weijermans, 3 weeks ago

Attachment: s.wav added

very short <200ms wav soundfile

comment:2 by Danny Weijermans, 3 weeks ago

thanks for your relevant link!
yes, but I'm not using a 'lossy' audio fileformat.
it's a 'firm' wav file, I have put an very short wav file (s.wav) example as an attachment.
my command line (which works on longer wav files) for example:
ffmpeg -i /Users/disjt/Desktop/s.wav -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png
if /Users/disjt/Desktop/s.wav points to a longer wav file it's working perfectly.
if it's a shorter than 200msec it's not working..

comment:3 by MasterQuestionable, 3 weeks ago

Component: ffmpegavfilter
Keywords: showwavespic added; waveform creation short audio removed
Summary: ffmpeg create waveform overview with short audiofiles doesn't work"showwavespic" filter failed with very short audio (< 200 ms)?

͏    https://ffmpeg.org/ffmpeg-filters.html#showwavespic

͏    Cannot reproduce?
͏    ffmpeg -y -v debug -hide_banner -nostdin -nostats -f lavfi -i "sine=d=0.1" -lavfi "showwavespic" "!.png"
͏    ffmpeg -y -v debug -hide_banner -nostdin -nostats -i "s.wav" -lavfi "showwavespic" "s.png"
͏    (tried very much your original command too)

͏    What's the FFmpeg version?

comment:4 by Danny Weijermans, 3 weeks ago

Hi! I used your code now:
ffmpeg -y -v debug -hide_banner -nostdin -nostats -i "s.wav" -lavfi "showwavespic" "s.png"
and now it works!
so what's the change? is -lavfi needed?
If you use my code, can't you reproduce? :
ffmpeg -i /Users/disjt/Desktop/s.wav -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png
I really need the 'mono' option (mix to mono), 'compand' to compress the dynamic range, and output a specific size: 8000x100
Can you reproduce this?

comment:5 by Danny Weijermans, 3 weeks ago

PS, I'm in ffmpeg 7.0.1 on a Mac

by Danny Weijermans, 3 weeks ago

Attachment: t.wav added

a very short <200ms wav STEREO soundfile 24bits

comment:6 by Danny Weijermans, 3 weeks ago

I also added a very short stereo soundfile: can you test it with this?
I get an empty file if I use the following code-line:

ffmpeg -y -v debug -hide_banner -nostdin -nostats -i /Users/disjt/Desktop/t.wav -filter_complex "compand,aformat=channel_layouts=mono,showwavespic=s=1400x100:colors=green" -frames:v 1 "t.png"

comment:7 by Danny Weijermans, 3 weeks ago

I guess it has something to do with the 'filter_complex' option and using "-frames:v 1" instead of using "-lavfi" ?

comment:8 by MasterQuestionable, 3 weeks ago

Version: unspecified7.0

͏    "-filter_complex" and "-lavfi" should be semantically equivalent. (mere alias)
͏    Does it make the difference for you?
͏    (I did tried your original command (comment:2) with only filenames differences: cannot reproduce git-master)

͏    The debug output also reports various information related.
͏    Do you spot anything abnormal?

Last edited 3 weeks ago by MasterQuestionable (previous) (diff)

comment:9 by Danny Weijermans, 3 weeks ago

Aha! I found it!
Now that I tried a smaller horizontal value (than 1400) it works:

so it must be, that for very short soundfiles the horizontal size has a maximum..

Do you know what's the limit? Or how this is related?
Thanks for all your comments!
No, I didn't find different behaviour between "-filter_complex" and "-lavfi",

but I wasn't familiar with "-lavfi".

Can you reproduce it, when using my '=s=1400x100:' on my given wav file?

comment:10 by Danny Weijermans, 3 weeks ago

I tested some more, and the 'compand' option, also has different behaviour for very short soundfiles.. but: why??

comment:11 by Danny Weijermans, 3 weeks ago

I notice that the debug option even mentions 'Too few samples' : but WHY? WHEN are there few samples, and what is it based on?

Last edited 3 weeks ago by Danny Weijermans (previous) (diff)

comment:12 by MasterQuestionable, 3 weeks ago

Summary: "showwavespic" filter failed with very short audio (< 200 ms)?"showwavespic" failed for "Too few samples"?
Version: 7.0git-master

͏    ffmpeg -y -v debug -hide_banner -nostdin -nostats -i "t.wav" -lavfi "showwavespic" "t.png"
͏    ; fails "[Parsed_showwavespic_0] Too few samples"
͏    "s=1400x100" not required.

͏    https://github.com/FFmpeg/FFmpeg/blob/8a951ef5e119afb41e67d8b7dc3dedadc88c0e41/libavfilter/avf_showwaves.c#L594
͏    https://github.com/search?type=code&q=repo:FFmpeg/FFmpeg+/(?-i)(?:%5CW|^)Too+few+samples(?:%5CW|%24)/
͏    https://github.com/search?type=code&q=repo:FFmpeg/FFmpeg+%22Too+few%22+sample
͏    .
͏    I wonder too.

͏    "compand" should be mostly irrelevant:
͏    https://ffmpeg.org/ffmpeg-filters.html#compand
͏    (is parameterless "compand" no-op..?) [ No. ]

Last edited 2 weeks ago by MasterQuestionable (previous) (diff)

by Danny Weijermans, 2 weeks ago

Attachment: FL.wav added

short soundfile with recognizable waveform

by Danny Weijermans, 2 weeks ago

Attachment: FLffmpeg.png added

ffmpeg showwavespic result: samples are truncated on the right side (or: not enough samples are shown)

by Danny Weijermans, 2 weeks ago

Attachment: FLright.png added

how the fl.wav should really look as a waveform

comment:13 by Danny Weijermans, 2 weeks ago

a new insight:
when using smaller widths, the wavesample picture gets truncated at the right sight
(or: the wavesample data is not comlete)
uploaded 3 new files:
FL.wav : a short wav file with a recognizable waveform
FLright.png : how FL.wav should look (in 'Snapper')
FLffmpeg.png: how FL.wav looks in ffmpeg showwavespic using for example:
ffmpeg -i /Users/disjt/Desktop/FL.wav -filter_complex "showwavespic=s=500x120" -frames:v 1 FL.png
can you replicate this?

in reply to:  12 ; comment:14 by Danny Weijermans, 2 weeks ago

Replying to MasterQuestionable:

͏    ffmpeg -y -v debug -hide_banner -nostdin -nostats -i "t.wav" -lavfi "showwavespic" "t.png"
͏    ; fails "[Parsed_showwavespic_0] Too few samples"
͏    "s=1400x100" not required.

I need a big width in order to have a proper horizontal resolution.
and this is where the 'bug' is..
When I set 1400 smaller for shorter soundfiles it gives results..

͏    https://github.com/FFmpeg/FFmpeg/blob/8a951ef5e119afb41e67d8b7dc3dedadc88c0e41/libavfilter/avf_showwaves.c#L594
͏    https://github.com/search?type=code&q=repo:FFmpeg/FFmpeg+/(?-i)(?:%5CW|^)Too+few+samples(?:%5CW|%24)/
͏    https://github.com/search?type=code&q=repo:FFmpeg/FFmpeg+%22Too+few%22+sample
͏    .
͏    I wonder too.

͏    "compand" should be mostly irrelevant:
͏    https://ffmpeg.org/ffmpeg-filters.html#compand
͏    (is parameterless "compand" no-op..?)

When I use 'compand' without parameters, it looks different (better) than without 'compand':
it shows the waveform a bit 'audio-compressed'..

in reply to:  14 comment:15 by MasterQuestionable, 2 weeks ago

͏    I mean it's just reproducible with the default 600x240: the same failure.

comment:16 by Danny Weijermans, 2 weeks ago

Okay, got it now! Thanks!
Also have a look at my last comment,

because that shines a new light on it
(not the complete number of samples get 'viewed')

by MasterQuestionable, 2 weeks ago

Attachment: FL.webp added

https://trac.ffmpeg.org/raw-attachment/ticket/11281/FL.webp

comment:17 by MasterQuestionable, 2 weeks ago

͏    Any width > 2048 fails "Too few samples"..?

Version 0, edited 2 weeks ago by MasterQuestionable (next)

comment:18 by Danny Weijermans, 2 weeks ago

Wow!
You mean: 'Any width < 2048 .
Yes I think so!

comment:19 by MasterQuestionable, 2 weeks ago

͏    Worth notice: "FL.wav" is of 2,048 samples.
͏    I guess "showwavespic" currently may not support resolution higher than 1 px/sample:
͏    Thus the "Too few samples" error.

comment:20 by Danny Weijermans, 2 weeks ago

so does that mean, if soundfiles have less than 2048 samples, I should set the resolution to the number of samples? I think so ;)

comment:21 by Danny Weijermans, 9 days ago

I can report, that it sort of works now for me:

when the soundfile has less than 2049 samples,
I'll set the horizontal pixel-width for 'showwavespic' to the number of samples


comment:22 by MasterQuestionable, 7 days ago

͏    Per the source (comment:12) it's somewhat more complex. ("column"?)
͏    Also I'm unsure if the mirrored display is intended. (disable?)

Note: See TracTickets for help on using tickets.