Browse Source

ffmpeg推流规则判断

任敬轩 3 năm trước cách đây
mục cha
commit
e0e265cc8b
2 tập tin đã thay đổi với 16 bổ sung13 xóa
  1. 15 12
      Modules/Camera/Services/CameraServices.php
  2. 1 1
      config/mine.php

+ 15 - 12
Modules/Camera/Services/CameraServices.php

@@ -981,20 +981,23 @@ class CameraServices
             mkdir('/www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path, 0777, true);
         }
 
-//        $mine_list = DB::table('mine_list')
-//            ->select('mine_list.degree')
-//            ->leftJoin('camera_list','camera_list.mine_id','=','mine_list.id')
-//            ->where('$camera_id',$camera_id)->get();
-//        $id = explode('|',$mine_list[0]->degree)[0];
-//        $mine_res = DB::table('mine_list')->where('id',$id)->get();
-//        if(in_array($mine_res[0]->title,config('mine_code'))){
-//            dd(123);
-//        }else{
-//            dd(456);
-//        }
+        $mine_list = DB::table('mine_list')
+            ->select('mine_list.degree')
+            ->leftJoin('camera_list','camera_list.mine_id','=','mine_list.id')
+            ->where('camera_list.id',$camera_id)->get();
+        if(isset($mine_list)){
+            $mine_id = explode('|',$mine_list[0]->degree)[0];
+            $mine_res = DB::table('mine_list')->where('id',$mine_id)->get();
+        }
+        //取流进程
+        if(isset($mine_res[0]->title) && in_array($mine_res[0]->title,config('mine'))){
+            $exec = 'nohup /usr/bin/ffmpeg -rtsp_transport tcp -i "' . $video_url . '" -b:v 200k -c:v libx264 -c:a copy -s 384*288 -vbsf h264_mp4toannexb -f hls -hls_flags delete_segments -segment_list_size 10 -hls_list_size 2 -threads 4 /www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' >/dev/null &';
+        }else{
+            $exec = 'nohup /usr/bin/ffmpeg -i "' . $video_url . '" -vcodec copy -acodec copy -vbsf h264_mp4toannexb -f hls -hls_flags delete_segments -segment_list_size 10 -hls_list_size 2 /www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' >/dev/null &';
+        }
 
         //取流进程
-        $exec = 'nohup /usr/bin/ffmpeg -i "' . $video_url . '" -vcodec copy -acodec copy -vbsf h264_mp4toannexb -f hls -hls_flags delete_segments -segment_list_size 10 -hls_list_size 2 /www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' >/dev/null &';
+//        $exec = 'nohup /usr/bin/ffmpeg -i "' . $video_url . '" -vcodec copy -acodec copy -vbsf h264_mp4toannexb -f hls -hls_flags delete_segments -segment_list_size 10 -hls_list_size 2 /www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' >/dev/null &';
 
 //        $exec = 'nohup /usr/bin/ffmpeg -rtsp_transport tcp -i "' . $video_url . '" -b:v 200k -c:v libx264 -c:a copy -s 384*288 -vbsf h264_mp4toannexb -f hls -hls_flags delete_segments -segment_list_size 10 -hls_list_size 2 -threads 4 /www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' >/dev/null &';
         shell_exec($exec);

+ 1 - 1
config/mine.php

@@ -1,4 +1,4 @@
 <?php
     return [
-        '金家渠'
+        '金家渠煤矿'
     ];