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

CORS error with S3 Bucket

Open avacoders opened this issue 2 years ago • 1 comments

Hello, I am using Laravel 10 and this package and Vue 2 and Video js for frontend. I am exporting the video to S3 bucket and also using encryption keys.

$lowBitrateFormat = (new X264('aac'))->setKiloBitrate(500);
        $midBitrateFormat = (new X264('aac'))->setKiloBitrate(1500);
        $highBitrateFormat = (new X264('aac'))->setKiloBitrate(3000);
        FFMpeg::fromDisk($this->video->disk)
            ->open($this->video->path)
            ->exportForHLS()
            ->toDisk('s3')
            ->addFormat($lowBitrateFormat)
            ->addFormat($midBitrateFormat)
            ->addFormat($highBitrateFormat)
            ->withRotatingEncryptionKey(function ($filename, $contents) {
                    Storage::disk('secrets')->put($filename, $contents);
                })
            ->save('videos/'.$this->video->id . '.m3u8');



and then getting this video as mentioned in docs

Route::get("/video/playlist/{playlist}", function($playlist){
    return FFmpeg::dynamicHLSPlaylist()
        ->fromDisk('s3')
        ->open("videos/$playlist")
        ->setKeyUrlResolver(function ($key) {
            return route('video.key', ['key' => $key]);
        })
        ->setPlaylistUrlResolver(function ($playlist) {
            return route('video.playlist', ['playlist' => $playlist]);
        })
        ->setMediaUrlResolver(function ($media) {
            return Storage::disk('s3')->url("videos/$media");
        });
})->name('video.playlist');

Route::get('/video/secret/{key}', function ($key) {
    return Storage::disk('secrets')->download($key);
})->name('video.key');

But in the website it is retrieving cors error : Failed to load response data: .....

In this case what should I do to fix this error

avacoders avatar Jul 07 '23 20:07 avacoders

You found any solution for this?

jackbaron avatar Oct 26 '23 02:10 jackbaron