Hi there,
on my site I am using a file.create:after
hook to create video thumbnails for videos that the editor uploads. Here is the thread were I got the code from.
The relevant code part looks like this:
'file.create:after' => function ($file) {
$filetype = $file->type();
if($filetype === 'video') {
// extract thumbnail from video file
try {
exec('ffmpeg -y -i ' . $file->root() . ' -ss 3 -t 1 -s 320x180 ' . $file->parent()->root() . '/' . F::name($file->filename()) . '_thumb.jpg');
} catch(Exception $e) {
echo 'Video thumbnail could not be extracted.';
echo $e->getMessage();
}
}
}
This works in my local setup, but it fails on my live server setup.
I do have ffmpeg set up on my live server, so I can connect to the server via ssh and then use ffmpeg there via the terminal. However, the thumbnails don’t get created on newly uploaded videos.
Since I have to turn off debugging on the live server now I don’t even know how to find out what is going wrong. Is it possible that the $file->root()
command does not extract the correct path on the live server? If so, how could I find out about that?
Or does anybody have any idea what else could be wrong?
Thanks!