laravel-ffmpeg icon indicating copy to clipboard operation
laravel-ffmpeg copied to clipboard

Add a way to set the encryption key static

Open dgagn opened this issue 2 years ago • 1 comments

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 avatar Aug 30 '23 00:08 dgagn

I can create a PR if needed

dgagn avatar Aug 30 '23 00:08 dgagn