<?php

namespace App\Service\Media;

use Symfony\Component\Process\Process;

class VideoThumbnailer
{
    public function generateThumbnail(string $videoPath, string $thumbPath, string $time = '00:00:01.000'): void
    {
        $command = [
            'ffmpeg',
            '-y',
            '-i', $videoPath,
            '-ss', $time,
            '-vframes', '1',
            $thumbPath
        ];

        $process = new Process($command);
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }
    }
}