|
@@ -27,33 +27,70 @@ class TestsController {
|
|
|
|
|
|
public function test()
|
|
|
{
|
|
|
- Input::replace(
|
|
|
- [
|
|
|
- 'url' => 'http://10.71.177.215:7000',
|
|
|
- 'username' => 'admin1',
|
|
|
- 'password' => 'Td123..',
|
|
|
- 'sysId' => 'PG',
|
|
|
- 'sId' => ["a066b080481649f9a7669e397cfd614f"],
|
|
|
- 'ip' => '10.71.177.215',
|
|
|
- 'port' => '1554',
|
|
|
- ]
|
|
|
- );
|
|
|
-
|
|
|
- $tdwy = new TdwyController();
|
|
|
- $result = $tdwy->getRtspById();
|
|
|
-
|
|
|
- $path = '金家渠煤矿/井下区域/摄像头';
|
|
|
- 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);
|
|
|
- }
|
|
|
- //取流进程
|
|
|
-// $exec = 'nohup /usr/bin/ffmpeg -i "' . $result['content'][0]['url'] . '" -fflags flush_packets -max_delay 1 -an -flags -global_header -hls_time 1 -hls_list_size 3 -hls_flags delete_segments+omit_endlist -vcodec copy -y /www/wwwroot/video.nxjiewei.com/public/' . CameraEnum::M3U8_FILE_PATH . '/' . $path . '/' . CameraEnum::M3U8_FILE_NAME . ' >/dev/null &';
|
|
|
+ $url = 'https://openapi.lechange.cn:443/openapi/accessToken' ;
|
|
|
+
|
|
|
+//当前的UTC时间戳
|
|
|
+ $time= strtotime(date('Y-m-d H:i:s',time()));
|
|
|
+
|
|
|
+//随机字符串
|
|
|
+ $nonce = md5(time());
|
|
|
+
|
|
|
+//授权信息之appid
|
|
|
+ $appId='lce9762cfccca541df';
|
|
|
+
|
|
|
+//授权信息之appSecret
|
|
|
+ $appSecret='58b95cc58f3948a782cd50ff8a1931';
|
|
|
+
|
|
|
+
|
|
|
+//拼接计算“签名原始串”
|
|
|
+ $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
|
|
|
+
|
|
|
+//计算摘要 sign
|
|
|
+ $sign=md5($signStr);
|
|
|
|
|
|
-// '/usr/bin/ffmpeg -i "rtsp://http://10.71.177.215:1554/s?dev=81906a00-ada9-4807-b07d-86b457f97925&sup=a1da52f60d3b422eb0c3b4832e8bbb20&supip=192.168.4.217&support=8000&ch=1&type=0" -fflags flush_packets -max_delay 1 -an -flags -global_header -hls_time 1 -hls_list_size 3 -hls_flags delete_segments+omit_endlist -vcodec copy -y /www/wwwroot/video.nxjiewei.com/public/files/video/m3u8/金家渠煤矿/金家渠地面/690水泵房东侧_通道1/20220318/out.m3u8';
|
|
|
+//业务参数
|
|
|
+ $params = [
|
|
|
|
|
|
- $exec = 'nohup /usr/bin/ffmpeg -i "' . $result['content'][0]['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 &';
|
|
|
- shell_exec($exec);
|
|
|
-// '/usr/bin/ffmpeg -i "rtsp://http://10.71.177.215:1554/s?dev=81906a00-ada9-4807-b07d-86b457f97925&sup=a1da52f60d3b422eb0c3b4832e8bbb20&supip=192.168.4.217&support=8000&ch=1&type=0" -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/files/video/m3u8/金家渠煤矿/金家渠地面/690水泵房东侧_通道1/20220318/out.m3u8';
|
|
|
- dd($exec);
|
|
|
+ ];
|
|
|
+
|
|
|
+//组装调用接口的body体内容
|
|
|
+ $data = json_encode([
|
|
|
+ 'system'=>
|
|
|
+ [
|
|
|
+ 'ver'=>'1.0',
|
|
|
+ 'sign'=>$sign,
|
|
|
+ 'appId'=>$appId,
|
|
|
+ 'time'=>$time,
|
|
|
+ 'nonce'=>$nonce
|
|
|
+ ],
|
|
|
+ 'params'=>empty($params)? new stdClass():$params,
|
|
|
+ 'id'=>'88'
|
|
|
+ ]);
|
|
|
+
|
|
|
+//http调用
|
|
|
+ $ret = $this->curl_post($data, $url);
|
|
|
+ $utf8 = iconv('utf-8', 'UTF-8', $ret);
|
|
|
+//调用后返回输出
|
|
|
+ echo $nonce.'result:<br>'.nl2br($utf8 ).'<br>';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function curl_post($data,$url)
|
|
|
+ {
|
|
|
+ $ch = curl_init();
|
|
|
+ $res= curl_setopt ($ch, CURLOPT_URL,$url);
|
|
|
+ var_dump($res);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
+ curl_setopt ($ch, CURLOPT_HEADER, 0);
|
|
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+ $result = curl_exec ($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ if ($result == NULL) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
}
|
|
|
}
|