本文介绍了如何在Laravel控制器中使用或导入ffmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过composer在我的项目中安装了laravel-ffmpeg

i have already installed the laravel-ffmpeg via composer in my project

composer require pbmedia/laravel-ffmpeg

然后我按照文档说明将类添加到config/app.php文件中

then i added class to config/app.php file as documentation says

//config/app.php

// config/app.php

'providers' => [
    ...
    ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class,
    ...
];

'aliases' => [
    ...
    'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class
    ...
];

然后发布此配置文件

php artisan vendor:publish --provider="ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider"

现在我的问题是在我的项目中使用此软件包,我应该如何在控制器中使用它?我看到了很多与此相关的帖子和​​问题,我得到了这些

now my question is to use this package in my project, how should i use this into my controlleri saw many post and ques regarding this and i get these

use FFMpeg;
use FFMpeg\FFMpeg;
use Pbmedia\LaravelFFMpeg\FFMpeg;
use ProtoneMedia\LaravelFFMpeg\FFMpeg;
.
.
.

哪个是正确的,我的目标是修剪视频,但是哪个对我来说很困惑

which one is correct, my goal is to trim a video, but which one works for that i am so confused

//config/laravel-ffmpeg.php

//config/laravel-ffmpeg.php

<?php

return [
    'ffmpeg' => [
        'binaries' => env('FFMPEG_BINARIES', 'ffmpeg'),
        'threads'  => 12,
    ],

    'ffprobe' => [
        'binaries' => env('FFPROBE_BINARIES', 'ffprobe'),
    ],

    'timeout' => 3600,

    'enable_logging' => true,

    'set_command_and_error_output_on_exception' => false,
];

请帮帮我,谢谢!

推荐答案

在类上方的控制器中使用以下代码

Use below code in your controller above class

use FFMpeg;
use FFMpeg\Coordinate\Dimension;
use FFMpeg\Format\Video\X264;

在控制器方法中使用FFMpeg打开文件

Open file using FFMpeg in your controller method

$media = FFMpeg::open($file_path);

这篇关于如何在Laravel控制器中使用或导入ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 08:30