|
@@ -490,6 +490,7 @@ class CameraServices
|
|
|
//根据摄像头id获取摄像头播放链接
|
|
|
public static function getRtspByCameraId($camera_id,$parent_id)
|
|
|
{
|
|
|
+
|
|
|
$result['status'] = true;
|
|
|
$result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
|
|
|
@@ -510,25 +511,23 @@ class CameraServices
|
|
|
$path .= '/' . $val['title'];
|
|
|
}
|
|
|
$path .= '/' . $query->camera_name;
|
|
|
-
|
|
|
+ // dd($path);
|
|
|
//标记摄像头为在线状态
|
|
|
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) {
|
|
|
+ if($query->revert_id != 'NullId'){
|
|
|
$result['data'] = [
|
|
|
'camera_id' => $camera_id,
|
|
|
- 'url' => env('EASY_DARWIN_JF_RTSP') . $path
|
|
|
+ 'url' => env('EASY_DARWIN_JF_RTSP') . $path
|
|
|
];
|
|
|
-
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
$mine_ext = MineListExt::where('mine_id', $parent_id)->first();
|
|
|
|
|
|
Input::replace(
|
|
@@ -551,7 +550,7 @@ class CameraServices
|
|
|
'url' => $result_td['content'][0]['url'],
|
|
|
'customPath' => $path,
|
|
|
];
|
|
|
-
|
|
|
+ // dd($data);
|
|
|
Log::info('请求流媒体服务器参数------------');
|
|
|
Log::info($data);
|
|
|
|
|
@@ -560,9 +559,12 @@ class CameraServices
|
|
|
//请求流媒体服务器拉流
|
|
|
$curl_res = curl_request($curl);
|
|
|
|
|
|
+
|
|
|
+ // DB::table('camera_list')->where('id',$camera_id)->update($res);
|
|
|
+ // dd($res);
|
|
|
Log::info('请求流媒体服务器result------------');
|
|
|
Log::info($curl_res);
|
|
|
-
|
|
|
+ CameraList::where('id', $camera_id)->update(['revert_id' => $curl_res]);
|
|
|
if (strpos($curl_res,' ')) {
|
|
|
//标记摄像头为异常状态
|
|
|
CameraList::where('id', $camera_id)->update(['camera_status' => CameraEnum::CAMERA_STATUS_ERROR]);
|
|
@@ -577,54 +579,7 @@ class CameraServices
|
|
|
'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', $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', $camera_id)->update(['cover_picture' => $picture_path]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //更新拉流id
|
|
|
- CameraList::where('id', $camera_id)->update(
|
|
|
- [
|
|
|
- 'revert_id' => trim($curl_res, '"'),
|
|
|
- 'updated_at' => date('Y-m-d H:i:s'),
|
|
|
- ]
|
|
|
- );
|
|
|
- return $result;
|
|
|
- } else {
|
|
|
- sleep(1);
|
|
|
- }
|
|
|
-
|
|
|
- $i++;
|
|
|
- }
|
|
|
-
|
|
|
- //标记摄像头为异常状态
|
|
|
- CameraList::where('id', $camera_id)->update(['camera_status' => CameraEnum::CAMERA_STATUS_ERROR]);
|
|
|
-
|
|
|
- $result['status'] = false;
|
|
|
- $result['msg'] = ApiEnum::EASY_DAWIN_REQUEST_FAIL;
|
|
|
return $result;
|
|
|
}
|
|
|
|