承接 synchro/laravel-medialibrary-audio 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

synchro/laravel-medialibrary-audio

最新稳定版本:v3.1.0

Composer 安装命令:

composer require synchro/laravel-medialibrary-audio

包简介

Audio file thumbnail generator for Spatie's Laravel Media Library

README 文档

README

This audio image generator generates thumbnails for audio files uploaded through Spatie's Media Library, just as it already does for image, video, and PDF formats. By default they look like this:

Example waveform image

Spatie's docs have more details of how plugins integrate with Media Library. Thumbnails of a mono waveform of the whole audio file are generated using ffmpeg's waveform converter. It uses the same PHP FFMpeg package that is used for the video formats already supported by Media Library, so there are no additional dependencies.

Installation & configuration

Install using composer with:

composer require synchro/laravel-medialibrary-audio 

Installing Spatie's Media Library (version 9.1.0 or later) in your Laravel project will generate a config file in config/media-library.php. Add the audio waveform generator to the list of generators in the image_generators section, including optionally setting default width, height, foreground and background properties (default values shown):

'image_generators' => [
    ...,
    Synchro\MediaLibrary\Conversions\ImageGenerators\AudioWaveform::class => [
        'width' => 2048,
        'height' => 2048,
        'foreground' => '#113554',
        'background' => '#CBE2F4', // or '' for transparent background
    ]
],

These parameters are optional - you can leave them out if you're happy with the defaults.

Thumbnail colours

The waveform is drawn in the foreground colour, over the background colour. Both should be specified using standard HTML 6-digit hex values (with a leading #) passed through the media library config, as above. You may also pass an empty string for background to generate a transparent background; make sure you use ->format('png') when registering media conversions on the model.

Thumbnail sizing

The base size of the thumbnails can be set via the media library config, as shown above. The default is 2048 x 2048 pixels, neutral values chosen because audio files have no inherent size or aspect ratio. This is quite large, but since the images are very simple, they will compress very well in PNG format. This size doesn't directly affect the thumbnails delivered to clients because media library itself generates scaled-down versions to match client requests, however, it does have a direct effect on the aspect ratio of the thumbnails, so if you want a 16:9 ratio, change the height to 1152, or 1536 for 4:3.

Supported formats

  • aiff
  • flac
  • m4a
  • mp3
  • mp4
  • ogg
  • wav
  • wma

Running tests

If your local ffmpeg installation is in a different path you can use the environment variables to define your own path:

FFMPEG_PATH=/usr/local/bin/ffmpeg FFPROBE_PATH=/usr/local/bin/ffprobe vendor/bin/phpunit

Or on recent macOS with homebrew:

FFMPEG_PATH=/opt/homebrew/bin/ffmpeg FFPROBE_PATH=/opt/homebrew/bin/ffprobe vendor/bin/phpunit

统计信息

  • 总下载量: 1.75k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 29
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-04