定制 motomedialab/bunny 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

motomedialab/bunny

Composer 安装命令:

composer require motomedialab/bunny

包简介

An integration with BunnyCDN to upload and check on the status of streamed videos

README 文档

README

MIT License Latest Version on Packagist Total Downloads Tests

This is an expanding library of bunny.net integrations developed by MotoMediaLab. Currently, it only supports uploading of videos via the Bunny Stream fetch method and some basic integration around this. As our requirements expand, this package will be updated with new functionality.

Installation

Installation can be achieved quickly and easily using Composer:

composer require motomedialab/bunny

Configuration

Below are the configuration parameters for Bunny Stream:

# library ID that videos should be uploaded to
BUNNY_STREAM_LIBRARY_ID=12345

# the CDN hostname for your stream configuration
BUNNY_STREAM_HOSTNAME=vz-xyz.b-cdn.net

# the API key for bunny stream (this is different from your account API key!)
BUNNY_STREAM_API_KEY=YOUR_API_KEY

Uploading a video

This library consolidates the process of uploading a video into a series of jobs. To upload a video, you need the URL of the video location and a title at a minimum.

// invokable class to trigger an upload job
app()->call(\Motomedialab\Bunny\Actions\UploadVideoFromUrl::class, [
    'url' => 'https://example.com/file.mp4',
    'title' => 'The video title'
]);

The Upload Flow

The upload process is designed to be entirely asynchronous, leveraging Laravel's queueing system. When you call the UploadVideoFromUrl invokable action, the following steps are initiated:

  1. An UploadVideoFromUrl job is dispatched to the queue.
  2. When the job is processed, it makes an API call to Bunny.net, instructing it to fetch the video from the specified URL.
  3. If the API call fails for any reason, a VideoUploadFailed event is dispatched and the process ends.
  4. On success, a CheckVideoTranscodingProgress job is dispatched to the queue with a 2-minute delay. This is to give Bunny.net time to start the transcoding process.
  5. The CheckVideoTranscodingProgress job will then:
    • Fire a VideoTranscoding event with the current progress of the transcoding.
    • If the transcoding is finished, a VideoTranscodingFinished event is fired.
    • If the transcoding fails, a VideoTranscodingFailed event is fired.
    • If the initial upload failed, a VideoUploadFailed event is fired.
    • If the video is still transcoding, the job will re-dispatch itself with a 30-second delay.

This cycle will continue until the video has finished transcoding or an error occurs.

Events

This package fires several events throughout the upload and transcoding process, allowing you to hook into the workflow and react accordingly.

Motomedialab\Bunny\Events\VideoTranscoding

This event is fired each time the CheckVideoTranscodingProgress job runs and the video is still transcoding. It provides the current progress of the transcoding, allowing you to display a progress bar or other feedback to the user.

Motomedialab\Bunny\Events\VideoTranscodingFinished

Once the video has been successfully transcoded, this event is fired. This is the point where you would typically update your database, associate the video with a model, and make it available to your users.

Motomedialab\Bunny\Events\VideoTranscodingFailed

If the transcoding process fails for any reason, this event will be fired. You can inspect the $event->video->transcodingMessages() to get more information on the type of failure.

Motomedialab\Bunny\Events\VideoUploadFailed

This event is dispatched if the initial upload fails. This can happen for a variety of reasons, such as an invalid URL or an API error. The event will contain the API error or video object where applicable, along with any metadata you passed.

Metadata

To track your conversion job throughout the process, we recommend sending metadata. This is shared throughout the workflow so you can react to the events later on.

// dispatch job with metadata
app()->call(\Motomedialab\Bunny\Actions\UploadVideoFromUrl::class, [
    'url' => 'https://example.com/file.mp4',
    'title' => 'The video title',
    'metadata' => [
        'model' => 'App\Models\Post',
        'model_id' => 12,
    ]
]);

// listen for the transcoding finished event
class VideoTranscodingListener
{
    public function __construct(\Motomedialab\Bunny\Events\VideoTranscodingFinished $event)
    {
        if ($event->metadata('model') === 'App\Models\Post') {
            // ToDo: find your post and assign the video...
        }
    }
}

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

motomedialab/bunny 适用场景与选型建议

motomedialab/bunny 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 295 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 motomedialab/bunny 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 295
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 38
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-16