Selaa lähdekoodia

修改获取图片封面图功能

qiuzijian 3 vuotta sitten
vanhempi
commit
af8a3828e8
2 muutettua tiedostoa jossa 11 lisäystä ja 9 poistoa
  1. 6 7
      .idea/workspace.xml
  2. 5 2
      Modules/Camera/Services/CameraServices.php

+ 6 - 7
.idea/workspace.xml

@@ -2,7 +2,6 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="b5beace6-e4f4-419b-8299-c67e17af5998" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/Modules/Camera/Http/Controllers/CameraController.php" beforeDir="false" afterPath="$PROJECT_DIR$/Modules/Camera/Http/Controllers/CameraController.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/Modules/Camera/Services/CameraServices.php" beforeDir="false" afterPath="$PROJECT_DIR$/Modules/Camera/Services/CameraServices.php" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -52,8 +51,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/Modules/Camera/Services/CameraServices.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="263">
-              <caret line="828" column="105" selection-start-line="828" selection-start-column="105" selection-end-line="828" selection-end-column="105" />
+            <state relative-caret-position="329">
+              <caret line="819" column="39" selection-start-line="819" selection-start-column="39" selection-end-line="819" selection-end-column="39" />
               <folding>
                 <element signature="e#129#150#0#PHP" expanded="true" />
               </folding>
@@ -438,12 +437,12 @@
       <workItem from="1641785500605" duration="61000" />
       <workItem from="1641786030534" duration="477000" />
       <workItem from="1641800375826" duration="26685000" />
-      <workItem from="1643085370753" duration="12644000" />
+      <workItem from="1643085370753" duration="12888000" />
     </task>
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="442695000" />
+    <option name="totallyTimeSpent" value="442939000" />
   </component>
   <component name="ToolWindowManager">
     <frame x="0" y="0" width="1440" height="900" extended-state="0" />
@@ -828,8 +827,8 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/Modules/Camera/Services/CameraServices.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="263">
-          <caret line="828" column="105" selection-start-line="828" selection-start-column="105" selection-end-line="828" selection-end-column="105" />
+        <state relative-caret-position="329">
+          <caret line="819" column="39" selection-start-line="819" selection-start-column="39" selection-end-line="819" selection-end-column="39" />
           <folding>
             <element signature="e#129#150#0#PHP" expanded="true" />
           </folding>

+ 5 - 2
Modules/Camera/Services/CameraServices.php

@@ -812,9 +812,12 @@ class CameraServices
                 //判断ts文件是否存在
                 $ts_exists = glob(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::TS_FILE_SUFFIX);
 
+                //查询是否存在封面图
+                $cover_picture = CameraList::where('id', $camera_id)->value('cover_picture');
+
                 if ($file_exists && $ts_exists) {
                     //查询是否存在封面图
-                    if (!$camera->cover_picture && $camera_id == 12032) {
+                    if (!$cover_picture && $camera_id == 12032) {
                         //获取第一帧作为封面图
                         $cover_exec = 'ffmpeg -i ' . public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" ' . public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::COVER_PICTURE_NAME;
                         exec($cover_exec);
@@ -822,7 +825,7 @@ class CameraServices
                         //判断图片是否存在
                         $picture_exists = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::COVER_PICTURE_NAME);
 
-                        if (!$picture_exists) {
+                        if ($picture_exists) {
                             //上传图片到oss并更新数据库
                             $picture_path = self::uploadOssFile(CameraEnum::COVER_PICTURE_NAME, public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/');
                             Log::info($picture_path);