1. 程式人生 > >php 視訊擷取 視訊切片

php 視訊擷取 視訊切片

<?php

namespace App\Http\Controllers;

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

class Home extends Controller
{
    //
    public function upload()
    {
        $ffmpeg = FFMpeg::create(array(
            'ffmpeg.binaries' => 'D:\phpStudy\php\php-7.0.12-nts\ffmpeg\bin\ffmpeg.exe',
            'ffprobe.binaries' => 'D:\phpStudy\php\php-7.0.12-nts\ffmpeg\bin\ffprobe.exe',
            'timeout' => 0,
            'ffmpeg.threads' => 12
        ));
        $video = $ffmpeg->open('source/movie.MP4');
        $clip = $video->clip(TimeCode::fromSeconds(30), TimeCode::fromSeconds(15));
        $clip->save(new X264(), 'video.avi');
        return 1111111;
    }
}