Repository navigation
Installation
composer require ogunsakin01/laravel-video-demos
php artisan video-demo:installvideo-demo:install sets everything up in one go, and is safe to run again (it is also the upgrade command):
| Step | What it does | Skip with |
|---|---|---|
| Config | Leaves the config in the package, set from .env. Removes a copy an older version made, if nobody edited it. |
|
| Migrations | Runs the package's own migrations only, never your app's pending ones. | |
| Recorder | Installs Playwright and Chromium into storage/video-demo/recorder, and checks that ffmpeg runs. |
--no-browser |
| Sample database | Builds the sample database from your migrations and seeders, with a user of each type. If it can't be built, you get a warning and everything else still works. | --no-sample-data |
| Queue | Restarts queue workers, so they run the new code. | |
| Local voice | With --with-voice, or by itself when a video or style here already uses it (as on a teammate's machine or in CI): the free local voice for voice-overs, about 500 MB once. Or run php artisan video-demo:install-voice any time. |
On the machine where you make videos:
ANTHROPIC_API_KEY=sk-ant-... # or another provider's key, see AI Providers and Costs
# Where your local app is served, if not APP_URL
VIDEO_DEMO_BASE_URL=https://myapp.test
# The name on the studio and library pages (default: "APP_NAME videos")
VIDEO_DEMO_NAME="Acme help videos"
# Optional: the user to record as when a video records on your own data
VIDEO_DEMO_LOGIN_AS=demo@example.com- Make sure
APP_URL(orVIDEO_DEMO_BASE_URL) is the address you open the app at, such ashttps://myapp.test, nothttp://localhost. The recorder and the library's links use it. - If you serve the app with
php artisan serve, give it a few workers (PHP_CLI_SERVER_WORKERS=4): the studio opens your pages in a browser while answering a request, and a single worker can't do both. - Don't record through Laravel Octane: see Sample Data. Herd, Valet,
php artisan serveand PHP-FPM all work.
Videos take minutes, so they run in a queue job. Start a worker for the package's own queue connection:
php artisan video-demo:workIt runs two workers, so two videos are made at once (--workers=4, or VIDEO_DEMO_WORKERS, for more), restarts any that stop, and stops them all on Ctrl+C. Each video opens its own browser on its own copy of the sample database, so they don't get in each other's way, but each needs memory and CPU, and your app must answer several requests at once: Herd, Valet, Sail and Octane do; with php artisan serve, set PHP_CLI_SERVER_WORKERS=4 or more. In production-like setups, run php artisan queue:work video-demo under Supervisor with numprocs set to the number you want.
The video-demo connection is a copy of your default queue connection with a retry_after of two hours. Without it, a video taking longer than your queue's retry_after (90 seconds in a new Laravel app) would be started a second time, and paid for twice. Your other workers don't pick these jobs up.
To use a connection of your own instead, set VIDEO_DEMO_QUEUE_CONNECTION and give it a retry_after of at least 1800 seconds. The studio warns you if it is shorter, or if the queue is sync.
Go to /video-demo/studio in your local app. It is only there while APP_ENV=local (or VIDEO_DEMO_STUDIO=true). See The Studio.
The recorder runs ffmpeg by default (brew install ffmpeg on a Mac, apt install ffmpeg on Ubuntu). To use another copy, such as one bundled with Remotion:
VIDEO_DEMO_FFMPEG=/full/path/to/ffmpegSome bundled builds need their own library folder to start; Remotion's macOS ffmpeg fails with "signal 6" without it. Wrap it in a script and point VIDEO_DEMO_FFMPEG at the script:
#!/bin/sh
# ~/.local/bin/ffmpeg-remotion (then: chmod +x ~/.local/bin/ffmpeg-remotion)
FF=/path/to/your-app/node_modules/@remotion/compositor-darwin-arm64 # -x64 on Intel Macs
DYLD_LIBRARY_PATH="$FF" exec "$FF/ffmpeg" "$@"video-demo:install warns if it can't run ffmpeg.
Playwright's own Chromium can't play MP4 (H.264). If your app shows videos, record with your installed Chrome:
VIDEO_DEMO_BROWSER_CHANNEL=chromeGetting started
Making videos
- The Studio
- Sample Data
- Styles and Screens
- Voice-over and Music
- Command Line
- Keeping Videos Up To Date
- Other Languages
- Separate Frontend
Showing videos
Going further
Help