|
@@ -347,9 +347,15 @@ class HaiKangController extends BaseController
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ if($query->code_stream == 2){
|
|
|
+ $code_stream = 0;
|
|
|
+ }else{
|
|
|
+ $code_stream = 1;
|
|
|
+ }
|
|
|
+
|
|
|
$url = $this->artemis.'/api/video/v1/cameras/previewURLs';
|
|
|
$params['cameraIndexCode'] = $query->index_code;
|
|
|
- $params['streamType'] = 1; //0主码流 1子码流 2第三码流
|
|
|
+ $params['streamType'] = $code_stream; //0主码流 1子码流 2第三码流
|
|
|
$params['protocol'] = 'rtsp';
|
|
|
$params['transmode'] = 1; //0:UDP 1:TCP
|
|
|
$params['expand'] = 'streamform=rtp';
|
|
@@ -380,7 +386,13 @@ class HaiKangController extends BaseController
|
|
|
|
|
|
if (strpos($curl_res,' ')) {
|
|
|
//切换码流重新获取rtsp
|
|
|
- $params['streamType'] = 0; //0主码流 1子码流 2第三码流
|
|
|
+ if($code_stream == 1){
|
|
|
+ $code_stream = 0;
|
|
|
+ }else{
|
|
|
+ $code_stream = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ $params['streamType'] = $code_stream; //0主码流 1子码流 2第三码流
|
|
|
|
|
|
$rtsp = $this->curlPost($this->pre_url . $url, json_encode($params));
|
|
|
|
|
@@ -416,6 +428,48 @@ class HaiKangController extends BaseController
|
|
|
'url' => env('EASY_DARWIN_JF_RTSP') . $path
|
|
|
];
|
|
|
|
|
|
+ //sleep10秒生成文件
|
|
|
+ $i = 1;
|
|
|
+ while ($i <= 10) {
|
|
|
+ //判断m3u8文件是否存在
|
|
|
+ $file_exists = file_exists(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . date('Ymd', time()) . '/' . CameraEnum::M3U8_FILE_NAME);
|
|
|
+ //判断ts文件是否存在
|
|
|
+ $ts_exists = glob(public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . date('Ymd', time()) . '/' . CameraEnum::TS_FILE_SUFFIX);
|
|
|
+ //查询是否存在封面图
|
|
|
+ $cover_picture = CameraList::where('id', Input::get('camera_id'))->value('cover_picture');
|
|
|
+
|
|
|
+ if ($file_exists && $ts_exists) {
|
|
|
+ //查询是否存在封面图
|
|
|
+ if (!$cover_picture) {
|
|
|
+ //获取第一帧作为封面图
|
|
|
+ $file_name = time() . CameraEnum::COVER_PICTURE_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 . '/' . date('Ymd', time()) . '/' . $file_name);
|
|
|
+
|
|
|
+ if ($picture_exists) {
|
|
|
+ //上传图片到oss并更新数据库
|
|
|
+ $picture_path = self::uploadOssFile($file_name, public_path() . '/' . CameraEnum::M3U8_FILE_PATH . $path . '/' . date('Ymd', time()) . '/');
|
|
|
+ CameraList::where('id', Input::get('camera_id'))->update(['cover_picture' => $picture_path]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ } else {
|
|
|
+ sleep(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //标记摄像头为异常状态
|
|
|
+ CameraList::where('id', Input::get('camera_id'))->update(['camera_status' => CameraEnum::CAMERA_STATUS_ERROR]);
|
|
|
+
|
|
|
+ $result['status'] = false;
|
|
|
+ $result['msg'] = ApiEnum::EASY_DAWIN_REQUEST_FAIL;
|
|
|
+
|
|
|
return $result;
|
|
|
}
|
|
|
|