MediaDB (API)
MediaDB is a web-based media streaming service written in Laravel and Vue.
- The nginx-vod-module is used for on-the-fly repackaging of MP4 files to DASH.
- The nginx-secure-token-module is used to prevent unwanted access and reading of streams. However CDN solutions may be preferred,
nginx-secure-token-module
provides support for several token providers.
Full size (old) screenshots are available on my Github repo.
MediaDB is very much in development and may not be suitable for production purposes. It is recommended to fork the project.
Installation
MediaDB requires a Laravel compatible development environment like Laravel Sail (included).
- ffmpeg including
ffprobe
- PHP 8.0 or later, with exif and GD support, including required extensions like
php-redis
andphp-imagick
. - Image optimizers
- MariaDB/MySQL (with JSON support), Redis and Supervisor.
- MeiliSearch
- Samples for testing.
Please consult the upstream documentation of used packages in composer.json
for possible other missing (OS) dependencies and/or recommendations.
Stream Server
MediaDB requires a DASH compatible nginx streaming environment:
Please consult the upstream documentation and the provided nginx config examples.
Front-end/app
- https://github.com/francoism90/mediadb-app - Optional front-end (SPA/PWA)/app (Capacitor) for MediaDB written in Vue and Quasar. Currently only tested on Android.
Note: it is recommend to clone/install MediaDB projects as subfolders, e.g. /var/www/html/api
(mediadb-api) and /var/www/html/app
(mediadb-app).
Nginx
See doc/nginx
for configuration examples.
Site | Domain | Details |
---|---|---|
mediadb-api.conf | localhost:3000 | API endpoint: Laravel instance, authentication, media processing, .. |
mediadb-app.conf | mediadb.test:443 mediadb.test:80 | MediaDB SPA/PWA, MediaDB API proxy. |
mediadb-vod.conf | stream.test:443 stream.test:80 | VOD: streaming endpoint, video mapping, thumbnail capture. |
mediadb-socket.conf | socket.mediadb.test:443 | Laravel Echo (broadcasting events). |
Laravel
See doc
for configuration examples.
cd /var/www/html/api
cp .env.example .env
composer install
php artisan horizon:install
php artisan telescope:install
php artisan migrate
php artisan key:generate
php artisan storage:link
php artisan scout:create-indexes
It is advisable to checkout all configuration files and change them when necessary, especially .env
, config/media.php
, config/video.php
, config/media-library.php
and config/filesystems.php
.
Seeders
php artisan db:seed
Generating VOD key + IV
dd if=/dev/urandom bs=1 count=32 2> /dev/null | xxd -p -c32
dd if=/dev/urandom bs=1 count=16 2> /dev/null | xxd -p -c32
.env
:
VOD_KEY=d5460ef7a5c2bece2d1b24e0d9959e5ea9beb9dd449080147bdba001e9106793
VOD_IV=722d4f9191c53d5e934e13719d02cced
mediadb-vod.conf
:
secure_token_encrypt_uri_key d5460ef7a5c2bece2d1b24e0d9959e5ea9beb9dd449080147bdba001e9106793;
secure_token_encrypt_uri_iv 722d4f9191c53d5e934e13719d02cced;
Set DASH encryption key
mediadb-vod.conf
:
vod_secret_key "mysecret-$vod_filepath";
Set VOD url
.env
:
VOD_URL=https://stream.test
mediadb-vod.conf
:
vod_base_url "https://stream.test";
vod_segments_base_url "https://stream.test";
Usage
To import files (videos, ..) to the library:
cd /var/www/html/api
php artisan video:import <path?>
Use the MediaDB app or any other custom front-end to retrieve the streaming data/manage media.
Notes
- Make sure files in the import and destination path are writeable by
http
(running user). - Make sure videos can be played in the browser/target device as they aren't being encoded (yet).
- Make sure there is enough space on the disk to import and process the media.
- See
app/Console/Commands/Video/ImportCommand.php
for more details.
Optimizing
composer install --optimize-autoloader --no-dev
php artisan optimize
Modules
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Credits
License
The MIT License (MIT). Please see License File for more information.