Skip to content

rate_init: Assertion `factor > 0' failed #7

@stuartcusackie

Description

@stuartcusackie

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions