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.63k stars 194 forks source link

how to add domain and url path in encryption key path ? #447

Closed magic-thomas closed 1 year ago

magic-thomas commented 1 year ago

Hi

I would like not to use laravel route for playing video.

I want to use just nginx rtmp hls module because of performance issue.

Now I can get this kind of m3u8 file content.

#EXT-X-KEY:METHOD=AES-128,URI="786ddd9c78c4756f.key",IV=0x8c633206543ff1585ed6d8c155699a21#EXT-X-KEY:METHOD=AES-128,URI="786ddd9c78c4756f.key",IV=0x8c633206543ff1585ed6d8c155699a21

But I want to get the full URI something like this.

#EXT-X-KEY:METHOD=AES-128,URI="http://domain.com/keys/786ddd9c78c4756f.key",IV=0x8c633206543ff1585ed6d8c155699a21#EXT-X-KEY:METHOD=AES-128,URI="786ddd9c78c4756f.key",IV=0x8c633206543ff1585ed6d8c155699a21

How can I do insert 'http://domain.com/keys/' in the m3u8 file for all key's URI ?

Is it possible with this package ?

magic-thomas commented 1 year ago

I just made function to replace URI.

    function replace_encryption_key_path($v_key, $filename) {

        $content = File::get($filename);
        $org = '#EXT-X-KEY:METHOD=AES-128,URI="';
        $replace =  $org . "/keys/" . $v_key . "/" ; 
        if( !  Str::contains( $content, $replace ) ) {
            $replaced = Str::replace( $org , $replace, $content);
            File::put($filename,  $replaced);
        }
    }

I wish It can be done with FFMPEG chain method.