Laravel FFMPEG添加HLS视频水印问题

时间:2020-06-06 17:19:57

标签: laravel ffmpeg

我在“ laravel / framework”:“ ^ 7.0”中使用“ pbmedia / laravel-ffmpeg”:“ ^ 7.0”,我想在HLS视频中添加水印,这是github中给出的示例回购https://github.com/pascalbaljetmedia/laravel-ffmpeg

FFMpeg::open(['video.mp4', 'video2.mp4'])
    ->export()
    ->addFilter(function(ComplexFilters $filters) {
        // $filters->watermark(...);
    });

但是它没有足够的信息,这是互联网上每种软件的有效示例

addFilter(function ($filters) {
            $filters->watermark($watermarkPath, [
                'position' => 'relative',
                'bottom' => 50,
                'right' => 50,
            ]);
        })

但是水印方法在库中还有两个必需的参数

addFilter(function (ComplexFilters $filters) {
            $filters->watermark($in,$watermarkPath,$out, [
                'position' => 'relative',
                'bottom' => 50,
                'right' => 50,
            ]);
        })

$ in和$ out我应该通过什么 这是我的完整代码

$low = (new X264('aac'))->setKiloBitrate(100);
$mid = (new X264('aac'))->setKiloBitrate(250);
$high = (new X264('aac'))->setKiloBitrate(500);


       FFMpeg::fromDisk('local')
        ->open($this->video->path)
        ->exportForHLS()
        ->addFilter(function (ComplexFilters $filters) {
            $filters->watermark(null,public_path('watermark.png'),null, [
                'position' => 'relative',
                'bottom' => 50,
                'right' => 50,
            ]);
        })
        ->addFormat($low)
        ->addFormat($mid)
        ->addFormat($high)
        ->save("public/videos/{$this->video->id}/{$this->video->id}.m3u8");

通过传递null我看不到任何水印,如果我删除这些null,则会出现错误

Please look at the required parameters in watermark function under ComplexFilters

请在ComplexFilters下的水印功能中查看所需的参数, 谢谢:)。

0 个答案:

没有答案