bbc / audiowaveform

C++ program to generate waveform data and render waveform images from audio files
https://waveform.prototyping.bbc.co.uk
GNU General Public License v3.0
1.92k stars 243 forks source link

Excellent with MP3s but problematic with WAVE files #128

Open Gigamick opened 4 years ago

Gigamick commented 4 years ago

When I use this on my application for MP3's it's all amazing. However I have some users uploading .WAV files and their waveform renders look like this:

Screenshot 2020-10-20 at 12 27 17

Which is very wrong. Any ideas?

chrisn commented 4 years ago

I'd be happy to investigate. Can you share an example WAV file with me? My contact email is in the commit history.

Gigamick commented 4 years ago

Thanks!! (ps I also emailed you....)

aerogus commented 2 years ago

I also have this "bug" with 60min length .wav file (pcm / 16 bits / stereo / 48kHz). All is saturated in the json export (all values are -127,+128 in 8 bits, or -32767,+32768 in 16 bits). The "bug" can be resolved by increasing the number of measurements (= decreasing --zoom param or decreasing --pixels-per-second param). But this increase a lot the weight of the json file.

Capture d’écran 2022-08-26 à 16 27 47

chrisn commented 2 years ago

Can you provide an example audio file for me to look at?

aerogus commented 2 years ago

here is the WAV file (680Mb) : https://wetransfer.com/downloads/610d0c275f83bd1f3e2a179e798e7cc620220826153809/c0ed2c8d4f2dc0db25bd6a2441af8fb020220826153828/998fa7

command executed :

% audiowaveform -i audiowaveform-test.WAV -o audiowaveform-test.json --zoom 172800 --bits 8 --split-channels
Input file: audiowaveform-test.WAV
Frames: 172800000
Sample rate: 48000 Hz
Channels: 2
Format: 0x10002
Sections: 1
Seekable: yes
Generating waveform data...
Samples per pixel: 172800
Input channels: 2
Output channels: 2
Done: 100%
Read 172800000 frames
Generated 1000 points
Output file: audiowaveform-test.json
Done

and excerpt of the json generated file :

{"version":2,"channels":2,"sample_rate":48000,"samples_per_pixel":172800,"bits":8,"length":1000,"data":[-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-127,124,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,-128,127,...]}

I set the zoom value at 172800 thinking there will be 1000 measurements (48000 * 3600 / 1000) ...

 % audiowaveform --version
AudioWaveform v1.6.0

OS MacOS 12.5.1 (Monterey). audiowaveform installed with homebrew

chrisn commented 2 years ago

Thanks, I've downloaded the file, I'll take a look.

chrisn commented 2 years ago

It's the same if I view in Audacity, the waveform is saturated. You see more detail with a lower zoom level, but if you need a fixed 1000 pixel width image, with this audio it'll just look like a solid block. So audiowaveform is working as designed. I wonder what ffmpeg is doing?

@Gigamick Did we figure out what was happening in your case? I don't remember the details, I apologise if I didn't reply...

aerogus commented 2 years ago

Thanks for your reply. The command i use with ffmpeg is the following :

ffmpeg -y -i audiowaveform-test.WAV \
-f lavfi -i color=s=960x540:c=0x292933 \
-filter_complex \
 "[0:a]showwavespic=s=960x540:colors=0xffffff:split_channels=1[waveform]; \
 [1:v][waveform]overlay=0:0" \
-frames:v 1 \
-hide_banner -loglevel warning \
audiowaveform-test.png