1
votes

I generated a waveform of the raw audio with ffmpeg and it looks as perfectly normal audio on the picture. But when I imported it in Audacity, I can see and hear that the audio is clipping.

I tried simple command:

ffmpeg -f s16le -ar 16000 -ac 1 -i audio.raw -lavfi showwavespic audio.png

With this result: waveform image 1

And also tried this solution https://stackoverflow.com/a/32276471/12253501

Looks much prettier, but still can't see that audio actually clipped: waveform image 2. For the second one I made sure to delete "compand=gain=-6" to get the actual audio level.

And here's what I see in Audacity: screenshot from Audacity

The audio I'm importing is raw data (16-bit signed PCM, Little-endian, 16000Hz Sample Rate). I also tried converting it to WAV first, but got the same results with ffmpeg and Audacity.

I'm wondering what I'm doing wrong and how to I get to see clipping on ffmpeg waveform output?

Here's the link for the audio file: raw and wav

2

2 Answers

1
votes

Your audio is definitely clipping. Try setting scale=log so you can see this better.

ffmpeg -i audio.wav -lavfi showwavespic=scale=log audio.png

Also keep in mind that some of this clipping may have occurred before this version of the file. If this is clipping on the input stage of the recorder, but the recorded output was down a few dB, then you can hear clipping but not necessarily see it in the raw levels.

Waveform

0
votes

I couldn't achieve the results I wanted with just the ffmpeg, and I end up using audiowaveform, which gave me result similar to Audacity. Not sure if it's RMS or Peak, but works for me. Unfortunately, audiowaveform can't work with raw audio:

ffmpeg -f s16le -ar 16000 -ac 1 -i audio.raw audio.wav
audiowaveform -i audio.wav -o audio.png -e 105

Other downside of audiowaveform is that by default it only generates waveform for the first 15 seconds. Needs to calculate the length of the audio and give it as a parameter (-e seconds).

Here's the result: waveform by audiowaveform