private function generateVideoPreview (HCResources $resource, string $storagePath, string $previewPath)
    {
        $fullPreviewPath = $storagePath . 'video-previews/' . $previewPath;

        if (!file_exists ($fullPreviewPath))
            mkdir ($fullPreviewPath, 0755, true);

        $videoPreview = $fullPreviewPath . '/preview_frame.jpg';

        if (!file_exists ($videoPreview)) {

            $videoPath = $storagePath . $resource->path;

            $ffmpeg = FFMpeg::create ([
                'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
                'ffprobe.binaries' => '/usr/bin/ffprobe',
                'timeout'          => 3600, // The timeout for the underlying process
                'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should use
            ]);

            $video    = $ffmpeg->open ($storagePath . $resource->path);
            $duration = $video->getFFProbe ()->format ($videoPath)->get ('duration');

            $video->frame (TimeCode::fromSeconds (rand (1, $duration)))
                ->save ($videoPreview);

            $resource->mime_type = 'image/jpg';
            $resource->path      = $videoPreview;
        }
    }