protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.62k stars 193 forks source link

Add a way to set the encryption key static #498

Open dgagn opened 1 year ago

dgagn commented 1 year ago

Instead of dynamic hls, why isn't there options for static? It will greatly improve this package as all the parts can be served with nginx. Something like :

        FFMpeg::fromDisk('uploads')
            ->open("{$this->argument('video')}.mp4")
            ->exportForHLS()
            ->addFormat($lowFormat, function (HLSVideoFilters $filters) {
                $filters->resize(1280, 720);
            })
            ->setKeyUrlResolver(function ($key) {
                return ...;
            })
            ->addFormat($midFormat, function (HLSVideoFilters $filters) {
                $filters->resize(1920, 1080);
            })
            ->addFormat($highFormat, function (HLSVideoFilters $filters) {
                // this will keep the original resolution but convert with higher bitrate
            })
            ->withRotatingEncryptionKey(function ($filename, $contents) {
                Storage::disk('secrets')->put($filename, $contents);
            }, 30)
            ->onProgress(function ($progress) {
                $this->info("Progress: {$progress}%");
            })
            ->toDisk('public')
            ->save("videos/{$this->argument('video')}.m3u8");
dgagn commented 1 year ago

I can create a PR if needed