audio-waveform-php icon indicating copy to clipboard operation
audio-waveform-php copied to clipboard

rate_init: Assertion `factor > 0' failed

Open stuartcusackie opened this issue 6 years ago • 0 comments

I've just started using your package. To be honest I have no idea about sox, it's the first I've heard of it.

I have it installed anyway but I am getting an error when running either: $waveform->getWaveformData($width) or $success = $waveform->getWaveform('thumbnail.png', 1024, 512);

Fatal error: Uncaught Exception: Failed to run sox command. Error: sox: rate.c:303: rate_init: Assertion 'factor > 0' failed. Aborted (core dumped) in /vendor/maximal/audio-waveform/Waveform.php on line 256

The error occurs on both local and remote mp3 files.

On further inspection it seems to be a 'Division by zero' problem, caused here (line 197): $needRate = 1.0 * $width * $samplesPerPixel * $this->getSampleRate() / $this->getSamples();

$this->getSamples() seems to be returning null and I might have narrowed it down further to (line 67): if (preg_match('/Duration.*[^\d](\d+)\s*samples?/ui', $str, $match))

There doesn't seem to be a 'Duration samples' line in my sox output

stuartcusackie avatar Apr 17 '20 17:04 stuartcusackie