Search by

wearejust / statamic-video-storage

TheBnl

There is no license information available for the latest version (0.0.1) of this package.

Package info

github.com/wearejust/statamic-video-storage

pkg:composer/wearejust/statamic-video-storage

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.0.1 2026-11-20 13:07 UTC

This package is auto-updated.

Last update: 2026-11-20 13:13:07 UTC


README

Store large videos with an external provider (Bunny Stream for now) and use them in Statamic content.

  • Direct uploads: files go straight from the browser to the provider through a signed (pre-signed) upload, so they never pass through your server.
  • Video library: a control panel page per container, with folders, search, previews, metadata fields, thumbnails, file replacement and deletion.
  • video_storage fieldtype: pick or upload videos from any blueprint. Entries store video IDs, so moving, renaming or replacing a video never breaks them.
  • Frontend output: Antlers, Blade and GraphQL get the video's details, playback URLs and metadata fields.

Setup

  1. Run the migration: php artisan migrate.

  2. Add your Bunny Stream library to .env:

    BUNNY_STREAM_LIBRARY_ID=
    BUNNY_STREAM_API_KEY=
    BUNNY_STREAM_READ_ONLY_API_KEY=
    BUNNY_STREAM_CDN_HOSTNAME=vz-xxxxxxxx-xxx.b-cdn.net
    # Only when "MP4 fallback" is enabled on the library:
    BUNNY_STREAM_MP4_FALLBACK=true
  3. In the Bunny library's settings, set the webhook URL to https://<your-site>/!/statamic-video-storage/webhooks/videos. Use the container's handle as the last segment. Webhooks are verified with the read-only API key, and they update a video's status once encoding finishes. For a local site, use polling instead (see below).

  4. Webhooks are handled by a queued job. Run a queue worker, or set the queue to sync.

  5. Give roles the Video Storage permissions per container: view, upload, edit folders, edit and delete videos.

Polling instead of webhooks

Bunny can't reach a site on localhost, so its webhooks never arrive there. Ask Bunny for the status instead:

VIDEO_STORAGE_SYNC=polling

With polling, the video library refreshes unfinished videos from Bunny every 10 seconds while it's open, and the scheduler runs php please video-storage:sync every minute. That command queues a sync for every video that's still uploading, encoding or being replaced (ignoring ones that haven't changed for a day). Run php artisan schedule:work to keep videos up to date without the library open. --all syncs every video, for example after missed webhooks, and --container=videos limits it to one container.

Importing videos added in Bunny

The library only knows videos uploaded through Statamic. To add videos that were uploaded in Bunny's dashboard or API, run:

php please video-storage:import

Imported videos land in the container's root folder, with their Bunny title. Videos Bunny hasn't received a file for yet are skipped. Use --dry-run to see what would be imported, and --container=videos for one container. To import regularly, schedule it in routes/console.php, for example Schedule::command('statamic:video-storage:import')->hourly();.

To change containers, publish the config: php artisan vendor:publish --tag=statamic-video-storage-config.

Containers and providers

config/statamic-video-storage.php lists containers, much like Laravel's filesystem disks. Each container has a driver, the driver's options, and a blueprint for the videos' metadata fields. The default blueprint, video, has a description field. Edit it in the control panel under Blueprints.

Register another provider (for example S3) by implementing Contracts\VideoProvider, and optionally Contracts\HandlesWebhooks and Contracts\ListsVideos (for importing):

VideoStorage::extend('s3', fn ($app, array $config) => new S3VideoProvider($config));

createUpload() returns a DirectUpload. The control panel supports the tus protocol (Bunny) and a plain pre-signed put request.

The fieldtype

Add a Video Storage field to a blueprint and choose its container. Settings:

  • Allow Uploads: let editors upload new videos from the field.
  • Max Videos: default 1, which stores a single ID. Leave it empty to allow any number.
  • Min Videos: the minimum number of videos.

The addon records which entries use which videos, and shows them in the library and when deleting a video. To rebuild that list, for example after an import, run php please video-storage:scan-usages.

Frontend output

The field returns a video, or a list of videos when Max Videos isn't 1. Missing videos are left out.

Key Description
id, title, container, folder Basic details
status, is_ready pending, processing, ready, failed or missing
duration, width, height Duration in seconds and original dimensions
hls HLS playlist URL
mp4 MP4 URL of the highest resolution, when MP4 fallback is enabled
thumbnail, preview Thumbnail and animated preview image URLs
embed URL of the provider's embeddable player
Blueprint fields The container's metadata fields, such as description

Antlers:

{{ hero_video }}
    <video-player src="{{ hls }}" poster="{{ thumbnail }}" title="{{ title }}"></video-player>
{{ /hero_video }}

GraphQL: each container has its own type, VideoStorageVideo_{Container}. It implements VideoStorageVideoInterface and adds the container's blueprint fields:

hero_video {
    id
    title
    is_ready
    hls
    thumbnail
    ... on VideoStorageVideo_Videos {
        description
    }
}

Development

The control panel code is in resources/js (Vue 3, TypeScript, Statamic UI components). Use Node 24 and pnpm:

pnpm install
pnpm typecheck
pnpm build

The build output in resources/dist is committed. Statamic publishes it to public/vendor/statamic-video-storage after statamic:install, or run php artisan vendor:publish --tag=statamic-video-storage --force.

Run the tests with composer test.