|
@@ -344,6 +344,19 @@ class HaiKangController extends BaseController
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ $degree = MineList::where('id', $query->mine_id)->value('degree');
|
|
|
|
+
|
|
|
|
+ $mine_list = MineList::whereIn('id', explode('|', $degree))->select(['title'])->get()->toArray();
|
|
|
|
+
|
|
|
|
+ $path = '';
|
|
|
|
+ foreach ($mine_list as $key => $val) {
|
|
|
|
+ $path .= '/' . $val['title'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $new_camera_name = str_replace('-','',$query->camera_name);
|
|
|
|
+ $new_camera_name = str_replace('#','号',$new_camera_name);
|
|
|
|
+ $path .= '/' . $new_camera_name;
|
|
|
|
+
|
|
if($query->code_stream == 2){
|
|
if($query->code_stream == 2){
|
|
$code_stream = 0;
|
|
$code_stream = 0;
|
|
}else{
|
|
}else{
|
|
@@ -363,6 +376,8 @@ class HaiKangController extends BaseController
|
|
|
|
|
|
$rtsp = json_decode($rtsp, true);
|
|
$rtsp = json_decode($rtsp, true);
|
|
|
|
|
|
|
|
+ $ffmpeg_rtsp = $rtsp['data']['url'];
|
|
|
|
+
|
|
$rtsp['data']['url'] = substr_replace($rtsp['data']['url'],env('NMJT_IP'),7,12);
|
|
$rtsp['data']['url'] = substr_replace($rtsp['data']['url'],env('NMJT_IP'),7,12);
|
|
|
|
|
|
$result['data'] = [
|
|
$result['data'] = [
|
|
@@ -370,9 +385,64 @@ class HaiKangController extends BaseController
|
|
'url' => $rtsp['data']['url']
|
|
'url' => $rtsp['data']['url']
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ //查询是否存在封面图
|
|
|
|
+ $cover_picture = CameraList::where('id', Input::get('camera_id'))->value('cover_picture');
|
|
|
|
+
|
|
|
|
+ if (!$cover_picture) {
|
|
|
|
+ register_shutdown_function(array($this, "getFirstPicture"),$path,$ffmpeg_rtsp);
|
|
|
|
+ }
|
|
|
|
+
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //宁煤集团获取rtsp流后获取首帧图片
|
|
|
|
+ public function getFirstPicture($path,$ffmpeg_rtsp){
|
|
|
|
+ if (!is_dir('/www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path)) {
|
|
|
|
+ mkdir('/www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path, 0777, true);
|
|
|
|
+ }
|
|
|
|
+ // dd($result_td['content'][0]['url']);
|
|
|
|
+ $exec = 'nohup /usr/bin/ffmpeg -i "' . $ffmpeg_rtsp . '" -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 &';
|
|
|
|
+
|
|
|
|
+ shell_exec($exec);
|
|
|
|
+
|
|
|
|
+ //sleep10秒生成文件
|
|
|
|
+ $i = 1;
|
|
|
|
+ while ($i <= 10) {
|
|
|
|
+ //判断m3u8文件是否存在
|
|
|
|
+ $file_exists = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . CameraEnum::M3U8_FILE_NAME);
|
|
|
|
+
|
|
|
|
+ //判断ts文件是否存在
|
|
|
|
+ $ts_exists = glob(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . CameraEnum::TS_FILE_SUFFIX);
|
|
|
|
+
|
|
|
|
+ if ($file_exists && $ts_exists) {
|
|
|
|
+
|
|
|
|
+ //获取第一帧作为封面图
|
|
|
|
+ $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;
|
|
|
|
+ exec($cover_exec);
|
|
|
|
+
|
|
|
|
+ //判断图片是否存在
|
|
|
|
+ $picture_exists = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . $file_name);
|
|
|
|
+
|
|
|
|
+ if ($picture_exists) {
|
|
|
|
+ $cms = new CameraServices();
|
|
|
|
+
|
|
|
|
+ //上传图片到oss并更新数据库
|
|
|
|
+ $picture_path = $cms->uploadOssFile($file_name, public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/');
|
|
|
|
+
|
|
|
|
+ CameraList::where('id', Input::get('camera_id'))->update(['cover_picture' => $picture_path]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ sleep(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $i++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//海康easy_drawin获取rtsp并推流
|
|
//海康easy_drawin获取rtsp并推流
|
|
public function getRtspByCameraId(){
|
|
public function getRtspByCameraId(){
|
|
$result['status'] = true;
|
|
$result['status'] = true;
|