瀏覽代碼

Update VideoPipeline

Daniel Supernault 6 年之前
父節點
當前提交
a1c29b50e3
共有 1 個文件被更改,包括 8 次插入8 次删除
  1. 8 8
      app/Jobs/VideoPipeline/VideoThumbnail.php

+ 8 - 8
app/Jobs/VideoPipeline/VideoThumbnail.php

@@ -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,14 +46,11 @@ 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);
-            if($video->getDurationInSeconds() < 1) {
-                $video->getFrameFromSeconds(0);
-            } elseif($video->getDurationInSeconds() < 5) {
-                $video->getFrameFromSeconds(4);
-            }
-            $video->export()
-                ->save($save);
+            $video = FFMpeg::open($base)
+            ->getFrameFromSeconds(1)
+            ->export()
+            ->toDisk('local')
+            ->save($save);
 
 
             $media->thumbnail_path = $save;
             $media->thumbnail_path = $save;
             $media->save();
             $media->save();