Browse Source

添加从硬盘录像机来源的摄像头读取封面图

qiuzijian 3 years ago
parent
commit
e5de7e6c48
2 changed files with 25 additions and 23 deletions
  1. 19 20
      .idea/workspace.xml
  2. 6 3
      Modules/Camera/Services/CameraServices.php

+ 19 - 20
.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$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" />
@@ -19,8 +18,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="-1273">
-              <caret line="370" column="27" selection-start-line="370" selection-start-column="27" selection-end-line="370" selection-end-column="27" />
+            <state relative-caret-position="548">
+              <caret line="460" column="163" selection-start-line="460" selection-start-column="163" selection-end-line="460" selection-end-column="163" />
               <folding>
                 <element signature="e#129#150#0#PHP" expanded="true" />
               </folding>
@@ -69,7 +68,7 @@
         <entry file="file://$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/CameraApiController.php">
           <provider selected="true" editor-type-id="text-editor">
             <state relative-caret-position="170">
-              <caret line="84" column="51" lean-forward="true" selection-start-line="84" selection-start-column="51" selection-end-line="84" selection-end-column="51" />
+              <caret line="84" column="48" lean-forward="true" selection-start-line="84" selection-start-column="48" selection-end-line="84" selection-end-column="48" />
               <folding>
                 <element signature="e#141#162#0#PHP" expanded="true" />
               </folding>
@@ -176,7 +175,6 @@
         <option value="$PROJECT_DIR$/storage/logs/laravel-2021-08-10.log" />
         <option value="$PROJECT_DIR$/Modules/Camera/Database/Migrations/2021_08_10_102022_add_cover_picture_to_camera_list.php" />
         <option value="$PROJECT_DIR$/config/app.php" />
-        <option value="$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/CameraApiController.php" />
         <option value="$PROJECT_DIR$/Modules/Mine/Http/Controllers/Api/MineApiController.php" />
         <option value="$PROJECT_DIR$/Modules/Mine/Services/MineServices.php" />
         <option value="$PROJECT_DIR$/Modules/Camera/Database/Migrations/2021_12_22_162404_add_field_to_camera_list.php" />
@@ -190,6 +188,7 @@
         <option value="$PROJECT_DIR$/app/Http/Controllers/TestsController.php" />
         <option value="$PROJECT_DIR$/app/Console/Commands/UpdateHkList.php" />
         <option value="$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/HaiKangController.php" />
+        <option value="$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/CameraApiController.php" />
         <option value="$PROJECT_DIR$/Modules/Camera/Services/CameraServices.php" />
       </list>
     </option>
@@ -423,12 +422,12 @@
       <workItem from="1641800375826" duration="26685000" />
       <workItem from="1643085370753" duration="22739000" />
       <workItem from="1644194909678" duration="1729000" />
-      <workItem from="1645500713676" duration="7088000" />
+      <workItem from="1645500713676" duration="8044000" />
     </task>
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="478189000" />
+    <option name="totallyTimeSpent" value="479145000" />
   </component>
   <component name="ToolWindowManager">
     <frame x="0" y="0" width="1440" height="900" extended-state="0" />
@@ -747,16 +746,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/HaiKangController.php">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="426">
-          <caret line="214" column="71" selection-start-line="214" selection-start-column="67" selection-end-line="214" selection-end-column="71" />
-          <folding>
-            <element signature="e#141#185#0#PHP" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/app/Console/Commands/StopStreamDelFiles.php">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="571">
@@ -794,10 +783,20 @@
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/HaiKangController.php">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="426">
+          <caret line="214" column="71" selection-start-line="214" selection-start-column="67" selection-end-line="214" selection-end-column="71" />
+          <folding>
+            <element signature="e#141#185#0#PHP" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
     <entry file="file://$PROJECT_DIR$/Modules/Camera/Http/Controllers/Api/CameraApiController.php">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="170">
-          <caret line="84" column="51" lean-forward="true" selection-start-line="84" selection-start-column="51" selection-end-line="84" selection-end-column="51" />
+          <caret line="84" column="48" lean-forward="true" selection-start-line="84" selection-start-column="48" selection-end-line="84" selection-end-column="48" />
           <folding>
             <element signature="e#141#162#0#PHP" expanded="true" />
           </folding>
@@ -806,8 +805,8 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/Modules/Camera/Services/CameraServices.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-1273">
-          <caret line="370" column="27" selection-start-line="370" selection-start-column="27" selection-end-line="370" selection-end-column="27" />
+        <state relative-caret-position="548">
+          <caret line="460" column="163" selection-start-line="460" selection-start-column="163" selection-end-line="460" selection-end-column="163" />
           <folding>
             <element signature="e#129#150#0#PHP" expanded="true" />
           </folding>

+ 6 - 3
Modules/Camera/Services/CameraServices.php

@@ -391,6 +391,9 @@ class CameraServices
         }
         $path .= '/' . $query->camera_name . $camera_id;
 
+        //标记摄像头为在线状态
+        CameraList::where('id', $camera_id)->update(['camera_status' => CameraEnum::CAMERA_STATUS_ONLINE]);
+
         //已有拉流id,直接返回拉流链接
         $has_file = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . date('Ymd', time()) . '/' . CameraEnum::M3U8_FILE_NAME);
         if ($has_file) {
@@ -447,15 +450,15 @@ class CameraServices
                 if (!$cover_picture) {
                     //获取第一帧作为封面图
                     $file_name = time() . CameraEnum::COVER_PICTURE_NAME;
-                    $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 . '/' . $file_name;
+                    $cover_exec = 'ffmpeg -i ' . public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . date('Ymd', time()) . '/' . CameraEnum::M3U8_FILE_NAME . ' -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" ' . public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . date('Ymd', time()) . '/' . $file_name;
                     exec($cover_exec);
 
                     //判断图片是否存在
-                    $picture_exists = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . $file_name);
+                    $picture_exists = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . date('Ymd', time()) . '/' . $file_name);
 
                     if ($picture_exists) {
                         //上传图片到oss并更新数据库
-                        $picture_path = self::uploadOssFile($file_name, public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/');
+                        $picture_path = self::uploadOssFile($file_name, public_path() . '/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . date('Ymd', time()) . '/');
                         CameraList::where('id', $camera_id)->update(['cover_picture' => $picture_path]);
                     }
                 }