synchro/laravel-medialibrary-audio 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

synchro/laravel-medialibrary-audio

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

synchro/laravel-medialibrary-audio 适用场景与选型建议

synchro/laravel-medialibrary-audio 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.84k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2020 年 11 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「media」 「audio」 「conversion」 「laravel」 「laravel-medialibrary」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 synchro/laravel-medialibrary-audio 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 synchro/laravel-medialibrary-audio 我们能提供哪些服务?
定制开发 / 二次开发

基于 synchro/laravel-medialibrary-audio 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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