laravel-medialibrary-audio
laravel-medialibrary-audio copied to clipboard
Improve background colour rendering
The current process for creating the waveform image is not ideal.
FFMpeg saves the waveform image as a transparent PNG file. We that read that file back in, and use the Spatie Image package to fill in the background before optimising and resaving back into the same PNG file. This background filling process isn't quite the right operation, and the waveform ends up with some white fringing against the background colour, though it doesn't look too terrible.
A better approach would be to generate an image filled with the background colour, then overlay the waveform on top if it, all in memory without having to save to an intermediate file. This would also eliminate the fringing.
We are missing two things though:
- The PHP FFMpeg package doesn't have the ability to extract a GD or Imagick image instance, only to save to a file
- The Spatie Image library isn't much use for creating images from scratch
So fixing this will probably also involve PRs on FFMPeg, and probably using some other image library to do the compositing.