海康威视摄像头都试rtsp流,web页面无法加载播放,所以就得转换成web页面可以播放的hls、rtmp等数据流来播放。
一:萤石云
使用萤石云平台,把rtsp转化成ezopen协议,然后使用组件UIKit
UIKit Javascript · 萤石开放平台API文档
二:
使用海康威视官网插件,或无插件版
三:使用安防平台预览url接口
根据不同的数据流返回不同的直播流,这里我主要用的hls的流来播放。hls取流有一个坑的就是摄像头编码得设置264.音频选择acc。
海康接口调用封装的是用php写的。
<?php
namespace AppModel;
header('Content-type:text/html; Charset=utf-8');
date_default_timezone_set('PRC');
class Haikang
{
public $pre_url = "https://host:443"; //安防平台故武器地址
protected $app_key = "appkey"; // key
protected $app_secret = "secret";
public $time ;//时间戳
public $content_type="application/json";//类型
public $accept="*/*" ;//accept
public $person_list_url = "/artemis/api/resource/v1/encodeDevice/get";//人员列表url
public $equipment_view_url = "/artemis/api/video/v1/cameras/previewURLs";//获取监控点预览取流URL
public function __construct($app_key='', $app_secret='')
{
if($app_key!='') $this->app_key = $app_key;
if($app_secret!='') $this->app_secret = $app_secret;
$this->charset = 'utf-8';
list($mse