forked from mirror/pixelfed
Update VideoPipeline
This commit is contained in:
parent
7f437d4714
commit
a1c29b50e3
|
@ -34,6 +34,9 @@ class VideoThumbnail implements ShouldQueue
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$media = $this->media;
|
$media = $this->media;
|
||||||
|
if($media->mime != 'video/mp4') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$base = $media->media_path;
|
$base = $media->media_path;
|
||||||
$path = explode('/', $base);
|
$path = explode('/', $base);
|
||||||
$name = last($path);
|
$name = last($path);
|
||||||
|
@ -43,13 +46,10 @@ class VideoThumbnail implements ShouldQueue
|
||||||
$i = count($path) - 1;
|
$i = count($path) - 1;
|
||||||
$path[$i] = $t;
|
$path[$i] = $t;
|
||||||
$save = implode('/', $path);
|
$save = implode('/', $path);
|
||||||
$video = FFMpeg::open($base);
|
$video = FFMpeg::open($base)
|
||||||
if($video->getDurationInSeconds() < 1) {
|
->getFrameFromSeconds(1)
|
||||||
$video->getFrameFromSeconds(0);
|
->export()
|
||||||
} elseif($video->getDurationInSeconds() < 5) {
|
->toDisk('local')
|
||||||
$video->getFrameFromSeconds(4);
|
|
||||||
}
|
|
||||||
$video->export()
|
|
||||||
->save($save);
|
->save($save);
|
||||||
|
|
||||||
$media->thumbnail_path = $save;
|
$media->thumbnail_path = $save;
|
||||||
|
|
Loading…
Reference in New Issue