diff --git a/core/CapManager.py b/core/CapManager.py
index a9f7c07..70f6054 100644
--- a/core/CapManager.py
+++ b/core/CapManager.py
@@ -1,21 +1,54 @@
import math
-import queue
import cv2
import threading
import time
from myutils.ConfigManager import myCongif
from myutils.MyDeque import MyDeque
-import subprocess as sp
+from myutils.MyLogger_logger import LogHandler
+
+class CapManager:
+ def __init__(self):
+ self.logger = LogHandler().get_logger("CapManager")
+ self.mycap_map = {} #source,VideoCaptureWithFPS
+ self.lock = threading.Lock()
+
+ def __del__(self):
+ pass
+
+ def start_get_video(self,source,type=1):
+ vcf = None
+ with self.lock:
+ if source in self.mycap_map:
+ vcf = self.mycap_map[source]
+ vcf.addcount()
+ else:
+ vcf = VideoCaptureWithFPS(source,type)
+ self.mycap_map[source] = vcf
+ return vcf
+
+ def stop_get_video(self,source):
+ with self.lock:
+ if source in self.mycap_map:
+ vcf = self.mycap_map[source]
+ vcf.delcount()
+ if vcf.icount == 0:
+ del self.mycap_map[source]
+ else:
+ self.logger.error("数据存在问题!")
+
+mCap = CapManager()
+
class VideoCaptureWithFPS:
'''视频捕获的封装类,是一个通道一个
打开摄像头 0--USB摄像头,1-RTSP,2-海康SDK
'''
def __init__(self, source,type=1):
- self.source = source
+ self.source = self.ensure_udp_transport(source)
self.width = None
self.height = None
self.bok = False
+ self.icount = 1 #引用次数
# GStreamer --- 内存占用太高,且工作环境的部署也不简单
# self.pipeline = (
# "rtspsrc location=rtsp://192.168.3.102/live1 protocols=udp latency=100 ! "
@@ -27,29 +60,28 @@ class VideoCaptureWithFPS:
# )
#self.cap = cv2.VideoCapture(self.pipeline, cv2.CAP_GSTREAMER)
- #FFmpeg --更加定制化的使用--但要明确宽高。。。
- # self.ffmpeg_cmd = [
- # 'ffmpeg',
- # '-rtsp_transport', 'udp',
- # '-i', 'rtsp://192.168.3.102/live1',
- # '-f', 'image2pipe',
- # '-pix_fmt', 'bgr24',
- # '-vcodec', 'rawvideo', '-'
- # ]
- # self.pipe = sp.Popen(self.ffmpeg_cmd, stdout=sp.PIPE, bufsize=10 ** 8)
# opencv -- 后端默认使用的就是FFmpeg -- 不支持UDP
-
self.running = True
#self.frame_queue = queue.Queue(maxsize=1)
self.frame_queue = MyDeque(5)
- #self.frame = None
- #self.read_lock = threading.Lock()
+ self.frame = None
+ self.read_lock = threading.Lock()
self.thread = threading.Thread(target=self.update)
self.thread.start()
+ def addcount(self):
+ self.icount += 1
+
+ def delcount(self):
+ self.icount -= 1
+ if self.icount ==0: #结束线程
+ self.release()
+
def openViedo_opencv(self,source):
- self.cap = cv2.VideoCapture(source)
+ self.cap = cv2.VideoCapture(source,cv2.CAP_FFMPEG)
+ # self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 3)
+
if self.cap.isOpened(): # 若没有打开成功,在读取画面的时候,已有判断和处理 -- 这里也要检查下内存的释放情况
self.width = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH))
self.height = int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
@@ -60,31 +92,67 @@ class VideoCaptureWithFPS:
else:
raise ValueError("无法打开视频源")
+ def ensure_udp_transport(self,source): #使用udp拉流时使用
+ # 检查 source 是否已经包含 '?transport=udp'
+ # if not source.endswith("?transport=udp"):
+ # # 如果没有,则添加 '?transport=udp'
+ # if "?" in source:
+ # # 如果已有其他查询参数,用 '&' 拼接
+ # source += "&transport=udp"
+ # else:
+ # # 否则直接添加 '?transport=udp'
+ # source += "?transport=udp"
+ return source
+
def update(self):
sleep_time = myCongif.get_data("cap_sleep_time")
reconnect_attempts = myCongif.get_data("reconnect_attempts")
-
+ frame_interval = 1 / (myCongif.get_data("verify_rate")+1)
+ last_frame_time = time.time()
while self.running:
try:
+ # ffmpeg_process = subprocess.Popen(
+ # ['ffmpeg', '-i', self.source, '-f', 'image2pipe', '-pix_fmt', 'bgr24', '-vcodec', 'rawvideo', '-'],
+ # stdout=subprocess.PIPE, stderr=subprocess.PIPE
+ # )
+ #读取帧后,对帧数据进行处理
+ # frame = np.frombuffer(raw_frame, np.uint8).reshape((480, 640, 3))
+ # frame = np.copy(frame) # 创建一个可写的副本
self.openViedo_opencv(self.source)
+ if not self.cap.isOpened():
+ raise RuntimeError("视频源打开失败")
failure_count = 0
self.bok = True
while self.running:
- ret, frame = self.cap.read()
- if not ret:
+ #subprocess-udp 拉流
+ #raw_frame = ffmpeg_process.stdout.read(640 * 480 * 3)
+ if self.cap.grab():
+ current_time = time.time()
+ if current_time - last_frame_time > frame_interval:
+ last_frame_time = current_time
+ ret, frame = self.cap.retrieve()
+ if ret:
+ # resized_frame = cv2.resize(frame, (int(self.width / 2), int(self.height / 2)))
+ #self.frame_queue.myappend(frame)
+ with self.read_lock:
+ self.frame = frame
+ failure_count = 0 # 重置计数
+ else:
failure_count += 1
- time.sleep(0.5) #休眠一段时间后重试
+ time.sleep(0.1) # 休眠一段时间后重试
if failure_count >= reconnect_attempts:
+ with self.read_lock:
+ self.frame = None
raise RuntimeError("无法读取视频帧")
continue
- self.frame_queue.myappend(frame)
- failure_count = 0 #重置计数
- # 跳过指定数量的帧以避免积压
- for _ in range(self.fps):
- self.cap.grab()
+ #正常结束,关闭进程,释放资源
+ #ffmpeg_process.terminate()
+ self.cap.release()
+ self.bok = False
except Exception as e:
print(f"发生异常:{e}")
+ #ffmpeg_process.terminate()
self.cap.release()
self.bok = False
print(f"{self.source}视频流,将于{sleep_time}秒后重连!")
@@ -95,37 +163,14 @@ class VideoCaptureWithFPS:
return
time.sleep(2)
total_sleep += 2
- #释放cap资源,由release调用实现
-
- #resized_frame = cv2.resize(frame, (int(self.width / 2), int(self.height / 2)))
- # with self.read_lock:
- # self.frame = frame
-
- # if self.frame_queue.full():
- # try:
- # #print("队列满---采集线程丢帧")
- # self.frame_queue.get(timeout=0.01) #这里不get的好处是,模型线程不会有None
- # except queue.Empty: #为空不处理
- # pass
- # self.frame_queue.put(frame)
-
- # if not self.frame_queue.full():
- # self.frame_queue.put(frame)
-
def read(self):
- '''
- 直接读视频原画面
- :param type: 0-大多数情况读取,1-绘制区域时读取一帧,但当前帧不丢,还是回队列
- :return:
- '''
- # with self.read_lock:
- # frame = self.frame.copy() if self.frame is not None else None
- # if frame is not None:
- # return True, frame
- # else:
- # return False, None
-
+ with self.read_lock:
+ frame = self.frame.copy() if self.frame is not None else None
+ if frame is not None:
+ return True, frame
+ else:
+ return False, None
# if not self.frame_queue.empty():
# try:
# frame = self.frame_queue.get(timeout=0.05)
@@ -136,15 +181,15 @@ class VideoCaptureWithFPS:
# #print("cap-frame None")
# return False, None
- ret = False
- frame = None
- if self.bok: #连接状态再读取
- frame = self.frame_queue.mypopleft()
- if frame is not None:
- ret = True
- else:
- print("____读取cap帧为空,采集速度过慢___")
- return ret, frame
+ # ret = False
+ # frame = None
+ # if self.bok: #连接状态再读取
+ # frame = self.frame_queue.mypopleft()
+ # if frame is not None:
+ # ret = True
+ # else:
+ # print("____读取cap帧为空,采集速度过慢___")
+ # return ret, frame
def release(self):
self.running = False
diff --git a/core/ChannelData.py b/core/ChannelData.py
index e0268e7..9cc7d3a 100644
--- a/core/ChannelData.py
+++ b/core/ChannelData.py
@@ -7,15 +7,17 @@ import threading
import cv2
import ffmpeg
import subprocess
+import select
from collections import deque
from myutils.MyLogger_logger import LogHandler
-from core.CapManager import VideoCaptureWithFPS
+from core.CapManager import mCap
from core.ACLModelManager import ACLModeManger
from model.plugins.ModelBase import ModelBase
from core.WarnManager import WarnData
from core.DataStruct import ModelinData,ModeloutData
from myutils.MyDeque import MyDeque
from myutils.ConfigManager import myCongif
+from myutils.mydvpp import bgr_to_yuv420
class ChannelData:
def __init__(self,channel_id,deque_length,icount_max,warnM):
@@ -25,7 +27,8 @@ class ChannelData:
self.warnM = warnM #报警线程管理对象--MQ
self.ffprocess = self.start_h264_encoder(myCongif.get_data("mywidth"),myCongif.get_data("myheight"))#基于frame进行编码
#视频采集相关
- self.cap = None #该通道视频采集对象
+ self.cap = None #该通道视频采集对象 还是vcf对象
+ self.source = None #rtsp 路径
self.frame_rate = myCongif.get_data("frame_rate")
self.frame_interval = 1.0 / int(myCongif.get_data("verify_rate"))
@@ -78,7 +81,6 @@ class ChannelData:
# except queue.Empty:
# self.logger.debug(f"{self.channel_id}--web--获取分析画面失败,队列空")
# return None
-
frame = self.frame_queue.mypopleft()
return frame
else: #如果没有运行,直接从cap获取画面
@@ -90,33 +92,11 @@ class ChannelData:
ret,buffer_bgr_webp = self._encode_frame(frame)
return buffer_bgr_webp
- # frame_bgr_webp = self.encode_frame_to_flv(frame)
- # return frame_bgr_webp
- return None
-
- def encode_frame_to_flv(self,frame):
- try:
- process = (
- ffmpeg
- .input('pipe:', format='rawvideo', pix_fmt='bgr24', s=f'{frame.shape[1]}x{frame.shape[0]}')
- .output('pipe:', format='flv',vcodec='libx264')
- .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True)
- )
- out, err = process.communicate(input=frame.tobytes())
-
- if process.returncode != 0:
- raise RuntimeError(f"FFmpeg encoding failed: {err.decode('utf-8')}")
-
- return out
-
- except Exception as e:
- print(f"Error during frame encoding: {e}")
return None
def update_last_frame(self,buffer):
if buffer:
self.frame_queue.myappend(buffer)
-
# with self.lock:
# self.last_frame = None
# self.last_frame = buffer
@@ -136,66 +116,126 @@ class ChannelData:
# pass
#------------h264编码相关---------------
- def start_h264_encoder(self,width, height): #宽高一样,初步定全进程一个
+ def start_h264_encoder(self,width, height): #宽高一样,初步定全进程一个 libx264 h264_ascend
process = subprocess.Popen(
['ffmpeg',
'-f', 'rawvideo',
- '-pix_fmt', 'bgr24',
+ '-pix_fmt', 'yuv420p',
'-s', f'{width}x{height}',
'-i', '-', # Take input from stdin
'-an', # No audio
- '-vcodec', 'h264_ascend',
- '-preset', 'ultrafast',
- '-f', 'h264', # Output format H.264
+ '-vcodec', 'libx264',
+ '-f', 'flv',
'-'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
return process
- def encode_frame_h264(self, frame):
- if self.process.poll() is not None:
- raise RuntimeError("FFmpeg process has exited unexpectedly.")
- # Write frame to stdin of the FFmpeg process
+ def close_h264_encoder(self):
+ self.ffprocess.stdin.close()
+ self.ffprocess.wait()
+
+ def encode_frame_h264_bak(self,frame):
try:
- self.process.stdin.write(frame.tobytes())
+ process = (
+ ffmpeg
+ .input('pipe:', format='rawvideo', pix_fmt='bgr24', s=f'{frame.shape[1]}x{frame.shape[0]}')
+ .output('pipe:', format='flv',vcodec='h264_ascend')
+ .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True)
+ )
+ out, err = process.communicate(input=frame.tobytes())
+ if process.returncode != 0:
+ raise RuntimeError(f"FFmpeg encoding failed: {err.decode('utf-8')}")
+ return out
except Exception as e:
- raise RuntimeError(f"Failed to write frame to FFmpeg: {e}")
+ print(f"Error during frame encoding: {e}")
+ return None
+ def encode_frame_h264(self, frame,timeout=1):
+ yuv_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV_I420)
+ if self.ffprocess.poll() is not None:
+ raise RuntimeError("FFmpeg process has exited unexpectedly.")
+ # Write frame to stdin of the FFmpeg process
+ try:
+ self.ffprocess.stdin.write(yuv_frame.tobytes())
+ self.ffprocess.stdin.flush()
# Capture the encoded output
- buffer_size = 1024 * 10 # Adjust this based on the size of the encoded frame
- encoded_frame = bytearray()
+ buffer_size = 1024 * 1 # Adjust this based on the size of the encoded frame
+ encoded_frame = bytearray()
+ start_time = time.time()
+
+ while True:
+ # Use select to handle non-blocking reads from both stdout and stderr
+ #ready_to_read, _, _ = select.select([self.ffprocess.stdout, self.ffprocess.stderr], [], [], timeout)
+ ready_to_read, _, _ = select.select([self.ffprocess.stdout.fileno(), self.ffprocess.stderr.fileno()],
+ [], [], timeout)
+
+ # Check if there's data in stdout (encoded frame)
+ if self.ffprocess.stdout.fileno() in ready_to_read:
+ chunk = self.ffprocess.stdout.read(buffer_size)
+ if chunk:
+ encoded_frame.extend(chunk)
+ else:
+ break # No more data to read from stdout
- while True:
- chunk = self.process.stdout.read(buffer_size)
- if not chunk:
- break
- encoded_frame.extend(chunk)
+ # Check if there's an error in stderr
+ if self.ffprocess.stderr.fileno() in ready_to_read:
+ error = self.ffprocess.stderr.read(buffer_size).decode('utf-8')
+ raise RuntimeError(f"FFmpeg error: {error}")
- if not encoded_frame:
- raise RuntimeError("No encoded data received from FFmpeg.")
+ # Timeout handling to avoid infinite blocking
+ if time.time() - start_time > timeout:
+ raise RuntimeError("FFmpeg encoding timed out.")
- # Optional: Check for errors in stderr
- # stderr_output = self.process.stderr.read()
- # if "error" in stderr_output.lower():
- # raise RuntimeError(f"FFmpeg error: {stderr_output}")
+ if not encoded_frame:
+ raise RuntimeError("No encoded data received from FFmpeg.")
- return bytes(encoded_frame)
+ # Optional: Check for errors in stderr
+ # stderr_output = self.process.stderr.read()
+ # if "error" in stderr_output.lower():
+ # raise RuntimeError(f"FFmpeg error: {stderr_output}")
+ return bytes(encoded_frame)
+
+ except Exception as e:
+ print(f"Error during frame encoding: {e}")
+ return None
+
+ def _frame_pre_work(self, frame):
+ '''
+ 对采集到的图片数据进行预处理,需要确保是在原图上进行的修改
+ :param frame:
+ :return:
+ '''
+ # ----------添加时间戳-------------
+ # 获取当前时间
+ current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ # 设置字体和位置
+ font = cv2.FONT_HERSHEY_SIMPLEX
+ position = (10, 30) # 时间戳在左上角
+ font_scale = 1
+ color = (255, 255, 255) # 白色
+ thickness = 2
+ # 在帧上绘制时间戳
+ cv2.putText(frame, current_time, position, font, font_scale, color, thickness, cv2.LINE_AA)
+ return frame
def _encode_frame(self,frame,itype=0):
ret = False
buffer_bgr_webp = None
- if itype == 0: #jpg
- ret, frame_bgr_webp = cv2.imencode('.jpg', frame, self.encode_param)
- if ret:
- buffer_bgr_webp = frame_bgr_webp.tobytes()
- elif itype == 1: #H264
- try:
- buffer_bgr_webp = self.encode_frame_h264(frame)
- ret = True
- except Exception as e:
- print(e)
- else:
- print("错误的参数!!")
+ if frame is not None:
+ if itype == 0: #jpg
+ self._frame_pre_work(frame) #对图片添加一些信息,目前是添加时间戳(model是入队列的时间,cap是发送前取帧的时间)
+ ret, frame_bgr_webp = cv2.imencode('.jpg', frame, self.encode_param)
+ if ret:
+ buffer_bgr_webp = frame_bgr_webp.tobytes()
+ elif itype == 1: #H264
+ try:
+ buffer_bgr_webp = self.encode_frame_h264(frame)
+ ret = True
+ except Exception as e:
+ print(e)
+ else:
+ print("错误的参数!!")
return ret,buffer_bgr_webp
#帧序列号自增 一个线程中处理,不用加锁
@@ -213,9 +253,10 @@ class ChannelData:
'''
ret = False
if self.cap:
- self.cap.release()
+ mCap.stop_get_video(self.source)
self.cap = None
- self.cap = VideoCaptureWithFPS(source,type)
+ self.cap = mCap.start_get_video(source,type)
+ self.source = source
if self.cap:
ret = True
return ret
@@ -229,7 +270,7 @@ class ChannelData:
return False
else:
if self.cap:
- self.cap.release()
+ mCap.stop_get_video(self.source)
self.cap = None
return True #一般不会没有cap
@@ -348,6 +389,9 @@ class ChannelData:
warntext = ""
if model and schedule[weekday][hour] == 1: #不在计划则不进行验证,直接返回图片
# 调用模型,进行检测,model是动态加载的,具体的判断标准由模型内执行 ---- *********
+ # bwarn = False
+ # warntext = ""
+ # time.sleep(2)
bwarn, warntext = model.verify(img, model_data,isdraw) #****************重要
# 对识别结果要部要进行处理
if bwarn:
diff --git a/core/ChannelManager.py b/core/ChannelManager.py
index 478d42c..969e078 100644
--- a/core/ChannelManager.py
+++ b/core/ChannelManager.py
@@ -121,7 +121,7 @@ class ChannelManager:
for i in range(5):
ret, frame = channel_data.cap.read()
if ret:
- ret, frame_bgr_webp = cv2.imencode('.jpg', frame,self.encode_param)
+ ret, frame_bgr_webp = cv2.imencode('.jpg', frame)
if ret:
# 将图像数据编码为Base64
img_base64 = base64.b64encode(frame_bgr_webp).decode('utf-8')
diff --git a/core/ModelManager.py b/core/ModelManager.py
index a1a91fc..34e7a39 100644
--- a/core/ModelManager.py
+++ b/core/ModelManager.py
@@ -50,8 +50,6 @@ class ModelManager:
self.warnM = WarnManager()
self.warnM.start_warnmanager_th()
-
-
#工作线程:cap+model
if channel_id ==0:
strsql = "select id,ulr,type from channel where is_work = 1;" #执行所有通道
diff --git a/model/plugins/ModelBase.py b/model/plugins/ModelBase.py
index f4ac02c..948e8c0 100644
--- a/model/plugins/ModelBase.py
+++ b/model/plugins/ModelBase.py
@@ -34,7 +34,7 @@ class ModelBase(ABC):
self._output_num = 0 # 输出数据个数
self._output_info = [] # 输出信息列表
self._is_released = True # 资源是否被释放
-
+ self.polygon = None #检测区域
self.system = myCongif.get_data("model_platform") #platform.system() #获取系统平台
self.do_map = { # 定义插件的入口函数 --
# POCType.POC: self.do_verify,
@@ -59,10 +59,10 @@ class ModelBase(ABC):
self.release()
def draw_polygon(self, img, polygon_points,color=(0, 255, 0)):
- self.polygon = Polygon(ast.literal_eval(polygon_points))
-
- points = np.array([self.polygon.exterior.coords], dtype=np.int32)
- cv2.polylines(img, points, isClosed=True, color=color, thickness=2)
+ if polygon_points and polygon_points.strip():
+ self.polygon = Polygon(ast.literal_eval(polygon_points))
+ points = np.array([self.polygon.exterior.coords], dtype=np.int32)
+ cv2.polylines(img, points, isClosed=True, color=color, thickness=2)
def is_point_in_region(self, point):
'''判断点是否在区域内,需要先执行draw_polygon'''
diff --git a/myutils/MyRtspManager.py b/myutils/MyRtspManager.py
new file mode 100644
index 0000000..93f32f2
--- /dev/null
+++ b/myutils/MyRtspManager.py
@@ -0,0 +1,52 @@
+import socket
+
+class MyRtspManager:
+ def __init__(self):
+ self.rtsp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ pass
+
+ def __del__(self):
+ pass
+
+ def _send_rtsp_request(self,request):
+ '''
+ 发送 RTSP 请求:按照 RTSP 协议的格式发送请求,例如 OPTIONS、DESCRIBE、SETUP 和 PLAY 请求。
+ :param socket:
+ :param request:
+ :return:
+ '''
+ self.rtsp_socket.sendall(request.encode())
+ response = self.rtsp_socket.recv(4096).decode()
+ print("Response:\n", response)
+ return response
+
+ def _connectRest(self,IP,Port):
+ #self.rtsp_socket.connect(('192.168.3.103', 554))
+ self.rtsp_socket.connect((IP, Port))
+ #需要补充重连机制
+
+ def startGetRtsp(self):
+ # 发送 OPTIONS 请求
+ request = "OPTIONS rtsp://192.168.3.103/live1 RTSP/1.0\r\nCSeq: 1\r\n\r\n"
+ self._send_rtsp_request(request)
+
+ # 发送 DESCRIBE 请求获取 SDP 信息
+ request = "DESCRIBE rtsp://192.168.3.103/live1 RTSP/1.0\r\nCSeq: 2\r\nAccept: application/sdp\r\n\r\n"
+ response = self._send_rtsp_request(request)
+
+ # 解析 SDP 信息,提取媒体信息(如视频轨道的端口、编码)
+ # 此处需解析返回的 response 来提取端口、编码等信息
+
+ # 发送 SETUP 请求来配置 RTP/RTCP 传输
+ request = "SETUP rtsp://192.168.3.103/live1/trackID=0 RTSP/1.0\r\nCSeq: 3\r\nTransport: RTP/AVP;unicast;client_port=5000-5001\r\n\r\n"
+ self._send_rtsp_request(request)
+
+ # 创建 UDP 套接字来接收 RTP 数据
+ rtp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ rtp_socket.bind(('0.0.0.0', 5000)) # 绑定到前面 SETUP 请求中指定的 client_port
+
+ while True:
+ rtp_packet, _ = rtp_socket.recvfrom(2048)
+ # 解析 RTP 包的头部,提取负载数据(视频帧)
+ # 可以根据负载类型解析 H264 或其他格式的帧数据
+ print(f"Received RTP packet of size {len(rtp_packet)}")
\ No newline at end of file
diff --git a/myutils/mydvpp.py b/myutils/mydvpp.py
new file mode 100644
index 0000000..1a48334
--- /dev/null
+++ b/myutils/mydvpp.py
@@ -0,0 +1,16 @@
+import cv2
+
+
+def bgr_to_yuv420(bgr_img):
+ # Step 1: Convert BGR to YUV 4:4:4
+ yuv_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2YUV)
+
+ # Step 2: Extract Y, U, V channels
+ Y, U, V = cv2.split(yuv_img)
+
+ # Step 3: Downsample U and V channels (Subsample by a factor of 2)
+ U_downsampled = cv2.resize(U, (U.shape[1] // 2, U.shape[0] // 2), interpolation=cv2.INTER_LINEAR)
+ V_downsampled = cv2.resize(V, (V.shape[1] // 2, V.shape[0] // 2), interpolation=cv2.INTER_LINEAR)
+
+ # Step 4: Combine Y, U_downsampled, V_downsampled to get YUV 4:2:0 format
+ return Y, U_downsampled, V_downsampled
\ No newline at end of file
diff --git a/myutils/myutil.py b/myutils/myutil.py
deleted file mode 100644
index e69de29..0000000
diff --git a/run.py b/run.py
index 34efe54..61d4fa3 100644
--- a/run.py
+++ b/run.py
@@ -4,23 +4,65 @@ import os
import platform
import shutil
import asyncio
+import uvicorn
+
from hypercorn.asyncio import serve
from hypercorn.config import Config
+
from myutils.MyTraceMalloc import MyTraceMalloc
-import threading
+import subprocess
print(f"Current working directory (run.py): {os.getcwd()}")
-web = create_app()
+app = create_app()
+
async def run_quart_app():
config = Config()
config.bind = ["0.0.0.0:5001"]
- await serve(web, config)
+ await serve(app, config)
def test():
mMM.test1()
+def run_subprocess():
+ # 启动子进程,用于接收 stdin 输入并通过 stdout 返回结果
+ process = subprocess.Popen(
+ ['python3', '-c', '''
+ import sys
+ # 从stdin读取输入
+ for line in sys.stdin:
+ # 处理输入并写回stdout
+ sys.stdout.write(f"Processed: {line}")
+ sys.stdout.flush() # 刷新stdout输出缓冲区
+ '''],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
+ )
+
+ # 发送输入数据到子进程的 stdin
+ input_data = "Hello, subprocess!\n"
+ print(f"Sending to subprocess: {input_data}")
+ process.stdin.write(input_data)
+ process.stdin.flush() # 确保输入被传递给子进程
+
+ # 从子进程的 stdout 读取返回数据
+ output = process.stdout.readline() # 读取一行输出
+ print(f"Received from subprocess: {output}")
+
+ # 检查是否有错误输出
+ error = process.stderr.read()
+ if error:
+ print(f"Error from subprocess: {error}")
+ else:
+ print("no error!!")
+
+ # 关闭 stdin,并等待子进程完成
+ process.stdin.close()
+ process.wait()
+
+
+
if __name__ == '__main__':
#test()
+ #run_subprocess()
system = platform.system()
if system == "Windows":
@@ -42,6 +84,7 @@ if __name__ == '__main__':
#mVManager.start_check_rtsp() #线程更新视频在线情况
#启动web服务
asyncio.run(run_quart_app())
+ #uvicorn.run("run:app", host="0.0.0.0", port=5001, workers=4,reload=True)
diff --git a/web/API/__init__.py b/web/API/__init__.py
index bdf772c..7f87974 100644
--- a/web/API/__init__.py
+++ b/web/API/__init__.py
@@ -1,4 +1,4 @@
from quart import Blueprint
#定义模块
api = Blueprint('api',__name__)
-from . import user,system,viedo,channel,model
+from . import user,system,viedo,channel,model,warn
diff --git a/web/API/viedo.py b/web/API/viedo.py
index 53c97af..b69d168 100644
--- a/web/API/viedo.py
+++ b/web/API/viedo.py
@@ -187,7 +187,7 @@ async def handle_channel(channel_id,websocket):
icount = 0
send_stime = time.time()
- await websocket.send(frame)
+ await websocket.send(b'frame:'+frame)
send_etime = time.time()
send_all_time = send_all_time + (send_etime - send_stime)
else:
@@ -196,7 +196,7 @@ async def handle_channel(channel_id,websocket):
if icount > error_max_count:
print(f"通道-{channel_id},长时间未获取图像,休眠一段时间后再获取。")
#icount = 0
- error_message = b"video_error"
+ error_message = b'error:video_error'
await websocket.send(error_message)
await asyncio.sleep(sleep_time) # 等待视频重连时间
@@ -209,7 +209,7 @@ async def handle_channel(channel_id,websocket):
# 每隔一定时间(比如5秒)计算一次帧率
if el_time >= 10:
fps = frame_count / el_time
- print(f"当前帧率: {fps} FPS,循环次数:{frame_count},花费总耗时:{all_time}S,get耗时:{get_all_time},send耗时:{send_all_time}")
+ print(f"{channel_id}当前帧率: {fps} FPS,循环次数:{frame_count},花费总耗时:{all_time}S,get耗时:{get_all_time},send耗时:{send_all_time}")
# 重置计数器和时间
frame_count = 0
all_time = 0
diff --git a/web/API/warn.py b/web/API/warn.py
new file mode 100644
index 0000000..4abacab
--- /dev/null
+++ b/web/API/warn.py
@@ -0,0 +1,40 @@
+from . import api
+from web.common.utils import login_required
+from quart import jsonify, request
+from core.DBManager import mDBM
+
+@api.route('/warn/search_warn',methods=['POST'])
+@login_required
+async def warn_get(): #新增算法
+ #获取查询参数
+ json_data = await request.get_json()
+ s_count = json_data.get('s_count','')
+ e_count = json_data.get('e_count','')
+ model_name = json_data.get('model_name','')
+ channel_id = json_data.get('channel_id','')
+ start_time = json_data.get('start_time','')
+ end_time = json_data.get('end_time','')
+
+ # 动态拼接 SQL 语句
+ sql = "SELECT * FROM warn WHERE 1=1"
+
+ if model_name:
+ sql += f" AND model_name = {model_name}"
+ if channel_id:
+ sql += f" AND channel_id = {channel_id}"
+ if start_time and end_time:
+ sql += f" AND creat_time BETWEEN {start_time} AND {end_time}"
+
+ # 增加倒序排列和分页
+ sql += f" ORDER BY creat_time DESC LIMIT {e_count} OFFSET {s_count}"
+
+ # 使用SQLAlchemy执行查询
+ try:
+ print(sql)
+ data = mDBM.do_select(sql)
+ # 将数据转换为JSON格式返回给前端
+ warn_list = [{"ID": warn[0], "model_name": warn[1], "video_path": warn[2], "img_path": warn[3],
+ "creat_time": warn[4], "channel_id": warn[5]} for warn in data]
+ return jsonify(warn_list)
+ except Exception as e:
+ return jsonify({"error": str(e)}), 500
diff --git a/web/__init__.py b/web/__init__.py
index f4b3cd1..4c5e75d 100644
--- a/web/__init__.py
+++ b/web/__init__.py
@@ -32,15 +32,13 @@ class MemcachedSessionInterface: #只是能用,不明所以
def create_app():
app = Quart(__name__)
- #app = cors(app, allow_credentials=True) #allow_origin:指定允许跨域访问的来源
- #相关配置--设置各种配置选项,这些选项会在整个应用程序中被访问和使用。
- # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
- # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = 'zfxxkj_2024_!@#'
+
if myCongif.get_data("model_platform") == "acl":
app.config['SESSION_TYPE'] = 'memcached' # session类型
elif myCongif.get_data("model_platform") =="cpu":
app.config['SESSION_TYPE'] = 'redis' # session类型
+
#app.config['SESSION_FILE_DIR'] = './sessions' # session保存路径
#app.config['SESSION_MEMCACHED'] = base.Client(('localhost', 11211))
app.config['SESSION_PERMANENT'] = True # 如果设置为True,则关闭浏览器session就失效。
diff --git a/web/main/static/resources/scripts/aiortc-client-new.js b/web/main/static/resources/scripts/aiortc-client-new.js
index 8edcdc5..2b42365 100644
--- a/web/main/static/resources/scripts/aiortc-client-new.js
+++ b/web/main/static/resources/scripts/aiortc-client-new.js
@@ -2,7 +2,8 @@ let video_list = {}; //element_id -- socket
let run_list = {}; //element_id -- runtag
let berror_state_list = {}; //element_id -- 错误信息显示
let m_count = 0;
-var channel_list = null;
+let connection_version = {}; // 保存每个 element_id 的版本号
+let channel_list = null;
const fourViewButton = document.getElementById('fourView');
const nineViewButton = document.getElementById('nineView');
@@ -127,15 +128,19 @@ document.getElementById('nineView').addEventListener('click', function() {
nineViewButton.classList.add('btn-primary');
});
-function generateVideoNodes(count) { //在这里显示视频-初始化
+function generateVideoNodes(count) { //在这里显示视频-初始化 ---这里使用重置逻辑
//结束在播放的socket
for(let key in video_list){
- const videoFrame = document.getElementById(`video-${key}`);
- const event = new Event('closeVideo');
- videoFrame.dispatchEvent(event);
-
- delete video_list[key];
+ //flv使用
+ // const videoFrame = document.getElementById(`video-${key}`);
+ // const event = new Event('closeVideo');
+ // videoFrame.dispatchEvent(event);
+
+ //通用关闭
+ run_list[key] = false;
+ video_list[key].close();
berror_state_list[key] = false;
+ delete video_list[key];
}
//切换窗口布局
const videoGrid = document.getElementById('videoGrid');
@@ -150,16 +155,15 @@ function generateVideoNodes(count) { //在这里显示视频-初始化
-
- ![Video Stream]()
-
+
`;
}
videoGrid.innerHTML = html;
+
+ //开始还原视频,获取视频接口
// if(m_count != 0){
- //获取视频接口
const url = `/api/viewlist?count=${count}`;
fetch(url)
.then(response => response.json())
@@ -170,7 +174,6 @@ function generateVideoNodes(count) { //在这里显示视频-初始化
nlist = data.nlist;
for(let i=0;i {
- console.log('WebSocket connection established');
- };
+function connect(channel_id,element_id,imgcanvas,ctx,offscreenCtx,offscreenCanvas,streamUrl) {
+ //判断是否有重复socket,进行删除
+ if(element_id in video_list) {
+ run_list[element_id] = false;
+ video_list[element_id].close();
+ delete video_list[element_id];
+ console.log("有历史数据未删干净!!---",element_id) //要不要等待待定
+ }
+ // 每次连接时增加版本号
+ const current_version = (connection_version[element_id] || 0) + 1;
+ connection_version[element_id] = current_version;
+ const socket = new WebSocket(streamUrl);
+ socket.binaryType = 'arraybuffer'; // 设置为二进制数据接收
+ socket.customData = { channel_id: channel_id, element_id: element_id,
+ imgcanvas:imgcanvas,ctx:ctx,offscreenCtx:offscreenCtx,offscreenCanvas:offscreenCanvas,
+ version_id: current_version,streamUrl:streamUrl}; // 自定义属性 -- JS异步事件只能等到当前同步任务(代码块)完成之后才有可能被触发。
+ //新的连接
+ video_list[element_id] = socket;
+ run_list[element_id] = true;
+ berror_state_list[element_id] = false;
+ imgcanvas.style.display = 'block';
+
+ // 处理连接打开事件
+ socket.onopen = function(){
+ console.log('WebSocket connection established--',socket.customData.channel_id);
+ };
- socket.onmessage = function(event) {
- const reader = new FileReader();
- reader.readAsArrayBuffer(event.data);
+ socket.onmessage = function(event) {
+ let el_id = socket.customData.element_id
+ let cl_id = socket.customData.channel_id
+ let imgcanvas = socket.customData.imgcanvas
+ let ctx = socket.customData.ctx
+ let offctx = socket.customData.offscreenCtx
+ let offscreenCanvas = socket.customData.offscreenCanvas
+
+ // 转换为字符串来检查前缀
+ let message = new TextDecoder().decode(event.data.slice(0, 6)); // 取前6个字节
+ if (message.startsWith('frame:')){
+ //如有错误信息显示 -- 清除错误信息
+ if(berror_state_list[el_id]){
+ removeErrorMessage(imgcanvas);
+ berror_state_list[el_id] = false;
+ }
+ // 接收到 JPG 图像数据,转换为 Blob
+ let img = new Image();
+ let blob = new Blob([event.data.slice(6)], { type: 'image/jpeg' });
+ // 将 Blob 转换为可用的图像 URL
+ img.src = URL.createObjectURL(blob);
+ //定义图片加载函数
+ img.onload = function() {
+ imgcanvas.width = offscreenCanvas.width = img.width;
+ imgcanvas.height = offscreenCanvas.height = img.height;
+
+ // 在 OffscreenCanvas 上绘制
+ offctx.clearRect(0, 0, imgcanvas.width, imgcanvas.height);
+ offctx.drawImage(img, 0, 0, imgcanvas.width, imgcanvas.height);
+ // 将 OffscreenCanvas 的内容复制到主 canvas
+ ctx.drawImage(offscreenCanvas, 0, 0);
+
+ // 用完就释放
+ URL.revokeObjectURL(img.src);
+ // blob = null
+ // img = null
+ // message = null
+ // event.data = null
+ // event = null
+ };
+ }else if(message.startsWith('error:')){
+ const errorText = new TextDecoder().decode(event.data.slice(6)); // 截掉前缀 'error:'
+ //目前只处理一个错误信息,暂不区分
+ displayErrorMessage(imgcanvas, "该视频源未获取到画面,请检查后刷新重试,默认两分钟后重连");
+ berror_state_list[el_id] = true;
+ }
+ };
- reader.onload = () => {
- const arrayBuffer = reader.result;
- const decoder = new TextDecoder("utf-8");
- const decodedData = decoder.decode(arrayBuffer);
+ socket.onclose = function() {
+ let el_id = socket.customData.element_id;
+ let cl_id = socket.customData.channel_id;
+ if(run_list[el_id] && socket.customData.version_id === connection_version[el_id]){
+ console.log(`尝试重新连接... Channel ID: ${cl_id}`);
+ setTimeout(() => connect(cl_id, el_id, socket.customData.imgcanvas,
+ socket.customData.ctx,socket.customData.streamUrl), 1000*10); // 尝试在10秒后重新连接
+ }
+ };
- if (decodedData === "video_error") { //video_error
- displayErrorMessage(imgElement, "该视频源未获取到画面,请检查后刷新重试,默认两分钟后重连");
- berror_state_list[element_id] = true;
- //socket.close(1000, "Normal Closure"); // 停止连接
- } else if(decodedData === "client_error"){ //client_error
- run_list[element_id] = false;
- displayErrorMessage(imgElement, "该通道节点数据存在问题,请重启或联系技术支持!");
- socket.close(1000, "Normal Closure"); // 停止连接
- berror_state_list[element_id] = true;
- }
- else {
- if(berror_state_list[element_id]){
- removeErrorMessage(imgElement);
- berror_state_list[element_id] = false;
- //console.log("移除错误信息!");
- }
- // 释放旧的对象URL
- if (imgElement.src) {
- URL.revokeObjectURL(imgElement.src);
- }
- //blob = new Blob([arrayBuffer], { type: 'image/jpeg' });
- imgElement.src = URL.createObjectURL(event.data);
- }
- };
+ socket.onerror = function() {
+ console.log(`WebSocket错误,Channel ID: ${socket.customData.channel_id}`);
+ socket.close(1000, "Normal Closure");
+ };
+}
- //图片显示方案二
-// if (imgElement.src) {
-// URL.revokeObjectURL(imgElement.src);
-// }
-// imgElement.src = URL.createObjectURL(event.data);
- };
+function connectToStream(element_id,channel_id,channel_name) {
+ console.log("开始连接视频",element_id,channel_id);
+ //更新控件状态--设置视频区域的标题
+ const titleElement = document.querySelector(`[data-frame-id="${element_id}"] .video-title`);
+ titleElement.textContent = channel_name;
+ //视频控件
+ //const imgElement = document.getElementById(`video-${element_id}`);
+ //imgElement.alt = `Stream ${channel_name}`;
+ const imgcanvas = document.getElementById(`video-${element_id}`);
+ const ctx = imgcanvas.getContext('2d')
+ // 创建 OffscreenCanvas
+ const offscreenCanvas = new OffscreenCanvas(imgcanvas.width, imgcanvas.height);
+ const offscreenCtx = offscreenCanvas.getContext('2d');
- socket.onclose = function() {
- if(run_list[element_id]){
- console.log(`尝试重新连接... Channel ID: ${channel_id}`);
- setTimeout(connect, 1000*10); // 尝试在10秒后重新连接
- }
- };
+ const streamUrl = `ws://${window.location.host}/api/ws/video_feed/${channel_id}`;
- socket.onerror = function() {
- console.log(`WebSocket错误,Channel ID: ${channel_id}`);
- socket.close(1000, "Normal Closure");
- };
- };
- connect();
+ //创建websocket连接,并接收和显示图片
+ connect(channel_id,element_id,imgcanvas,ctx,offscreenCtx,offscreenCanvas,streamUrl); //执行websocket连接 -- 异步的应该会直接返回
}
function closeVideo(id) {
- const titleElement = document.querySelector(`[data-frame-id="${id}"] .video-title`);
- if (titleElement.textContent === `Video Stream ${Number(id)+1}`) {
- showModal('当前视频窗口未播放视频。');
- return;
- };
- console.log('closeVideo');
- //发送视频链接接口
- const url = '/api/close_stream';
- const data = {"element_id":id};
- // 发送 POST 请求
- fetch(url, {
- method: 'POST', // 指定请求方法为 POST
- headers: {
- 'Content-Type': 'application/json' // 设置请求头,告诉服务器请求体的数据类型为 JSON
- },
- body: JSON.stringify(data) // 将 JavaScript 对象转换为 JSON 字符串
- })
- .then(response => response.json()) // 将响应解析为 JSON
- .then(data => {
- console.log('Success:', data);
- const istatus = data.status;
- if(istatus == 0){
- showModal(data.msg); // 使用 Modal 显示消息
+ if(id in video_list) {
+ const imgcanvas = document.getElementById(`video-${id}`);
+ const titleElement = document.querySelector(`[data-frame-id="${id}"] .video-title`);
+ //断socket
+ run_list[id] = false;
+ video_list[id].close();
+ delete video_list[id];
+ //清空控件状态
+ imgcanvas.style.display = 'none'; // 停止播放时隐藏元素
+ titleElement.textContent = `Video Stream ${id+1}`;
+ removeErrorMessage(imgcanvas);
+ berror_state_list[id] = false;
+ //删记录
+ const url = '/api/close_stream';
+ const data = {"element_id":id};
+ // 发送 POST 请求
+ fetch(url, {
+ method: 'POST', // 指定请求方法为 POST
+ headers: {
+ 'Content-Type': 'application/json' // 设置请求头,告诉服务器请求体的数据类型为 JSON
+ },
+ body: JSON.stringify(data) // 将 JavaScript 对象转换为 JSON 字符串
+ })
+ .then(response => response.json()) // 将响应解析为 JSON
+ .then(data => {
+ console.log('Success:', data);
+ const istatus = data.status;
+ if(istatus == 0){
+ showModal(data.msg); // 使用 Modal 显示消息
+ return;
+ }
+ })
+ .catch((error) => {
+ showModal(`Error: ${error.message}`); // 使用 Modal 显示错误信息
return;
- }
- else{
- const videoFrame = document.querySelector(`[data-frame-id="${id}"] .video-area img`);
- const titleElement = document.querySelector(`[data-frame-id="${id}"] .video-title`);
- run_list[id] = false;
- video_list[id].close();
- delete video_list[id];
-
- videoFrame.src = ''; // 清空画面
- videoFrame.style.display = 'none'; // 停止播放时隐藏 img 元素
- titleElement.textContent = `Video Stream ${id+1}`;
- removeErrorMessage(videoFrame);
- berror_state_list[id] = false;
- }
- })
- .catch((error) => {
- showModal(`Error: ${error.message}`); // 使用 Modal 显示错误信息
+ });
+ }
+ else{
+ showModal('当前视频窗口未播放视频。');
return;
- });
+ }
}
function startFLVStream(element_id,channel_id,channel_name) {
diff --git a/web/main/static/resources/scripts/channel_manager.js b/web/main/static/resources/scripts/channel_manager.js
index 796df2c..4fdc00f 100644
--- a/web/main/static/resources/scripts/channel_manager.js
+++ b/web/main/static/resources/scripts/channel_manager.js
@@ -19,7 +19,7 @@ let m_polygon = "";
let check_area = 0;
let draw_status = false; //是否是绘制状态,处于绘制状态才能开始绘制
let b_img = false; //有没有加载图片成功,如果没有初始化的时候就不绘制线条了。
-let points = [];
+let points = []; //检测区域的点坐标数组
//布防计划
@@ -269,8 +269,9 @@ function configureAlgorithm(row) {
b_img = false;
document.getElementById('but_hzqy').textContent = "绘制区域";
//开始初始化算法管理模块
- show_channel_img(cid); //获取并显示一帧图片 -- 获取不到图片就是黑画面
show_channel_model_schedule(cid); //获取并显示结构化数据
+ show_channel_img(cid); //获取并显示一帧图片 -- 获取不到图片就是黑画面 --并要绘制检测区域
+
//显示窗口
$('#MX_M').modal('show');
}
@@ -304,8 +305,9 @@ img.onload = () => { //清除、画图和画线应该分开
backgroundCanvas.height = canvas.height = img.height;
// 将图片绘制到背景画布上
backgroundCtx.drawImage(img, 0, 0, img.width, img.height);
+ drawLines();
// 将背景画布的内容复制到前台画布上
- ctx.drawImage(backgroundCanvas, 0, 0, canvas.width, canvas.height); //绘制画面
+ //ctx.drawImage(backgroundCanvas, 0, 0, canvas.width, canvas.height); //绘制画面
};
//开始和重新绘制
@@ -462,7 +464,6 @@ function show_channel_model_schedule(cid){
if(m_polygon !== ""){ //指定区域了,一般是会有数据的。
const coords = parseCoordStr(m_polygon);
points = coords;
- drawLines();
}
}
//阈值
diff --git a/web/main/static/resources/scripts/flv.min.js b/web/main/static/resources/scripts/flv.min.js
new file mode 100644
index 0000000..c5010fb
--- /dev/null
+++ b/web/main/static/resources/scripts/flv.min.js
@@ -0,0 +1,10 @@
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.flvjs=t():e.flvjs=t()}(self,(function(){return function(){var e={264:function(e,t,i){
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
+ * @version v4.2.8+1e68dce6
+ */
+e.exports=function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function t(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=0,s=void 0,o=void 0,a=function(e,t){b[r]=e,b[r+1]=t,2===(r+=2)&&(o?o(E):A())};function h(e){o=e}function u(e){a=e}var l="undefined"!=typeof window?window:void 0,d=l||{},c=d.MutationObserver||d.WebKitMutationObserver,f="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),_="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){return function(){return process.nextTick(E)}}function m(){return void 0!==s?function(){s(E)}:y()}function g(){var e=0,t=new c(E),i=document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=e=++e%2}}function v(){var e=new MessageChannel;return e.port1.onmessage=E,function(){return e.port2.postMessage(0)}}function y(){var e=setTimeout;return function(){return e(E,1)}}var b=new Array(1e3);function E(){for(var e=0;e0&&o.length>r&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=l.bind(n);return r.listener=i,n.wrapFn=r,r}function c(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)n(h,this,t);else{var u=h.length,l=_(h,u);for(i=0;i=0;s--)if(i[s]===t||i[s].listener===t){o=i[s].listener,r=s;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return c(this,e,!0)},s.prototype.rawListeners=function(e){return c(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},397:function(e,t,i){function n(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.i=function(e){return e},i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},i.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i.oe=function(e){throw console.error(e),e};var n=i(i.s=ENTRY_MODULE);return n.default||n}var r="[\\.|\\-|\\+|\\w|/|@]+",s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function o(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(e,t,n){var a={};a[n]=[];var h=t.toString(),u=h.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return a;for(var l,d=u[1],c=new RegExp("(\\\\n|\\W)"+o(d)+s,"g");l=c.exec(h);)"dll-reference"!==l[3]&&a[n].push(l[3]);for(c=new RegExp("\\("+o(d)+'\\("(dll-reference\\s('+r+'))"\\)\\)'+s,"g");l=c.exec(h);)e[l[2]]||(a[n].push(l[1]),e[l[2]]=i(l[1]).m),a[l[2]]=a[l[2]]||[],a[l[2]].push(l[4]);for(var f,_=Object.keys(a),p=0;p<_.length;p++)for(var m=0;m0}),!1)}e.exports=function(e,t){t=t||{};var r={main:i.m},s=t.all?{main:Object.keys(r.main)}:function(e,t){for(var i={main:[t]},n={main:[]},r={main:{}};h(i);)for(var s=Object.keys(i),o=0;o=e[r]&&t0&&e[0].originalDts=t[r].dts&&et[n].lastSample.originalDts&&e=t[n].lastSample.originalDts&&(n===t.length-1||n0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){for(var t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null},e}()},949:function(e,t,i){"use strict";i.d(t,{Z:function(){return R}});var n=i(716),r=i.n(n),s=i(300),o=i(538),a=i(118);function h(e,t,i){var n=e;if(t+i=128){t.push(String.fromCharCode(65535&s)),n+=2;continue}}else if(i[n]<240){if(h(i,n,2))if((s=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2])>=2048&&55296!=(63488&s)){t.push(String.fromCharCode(65535&s)),n+=3;continue}}else if(i[n]<248){var s;if(h(i,n,3))if((s=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3])>65536&&s<1114112){s-=65536,t.push(String.fromCharCode(s>>>10|55296)),t.push(String.fromCharCode(1023&s|56320)),n+=4;continue}}t.push(String.fromCharCode(65533)),++n}return t.join("")},d=i(29),c=(u=new ArrayBuffer(2),new DataView(u).setInt16(0,256,!0),256===new Int16Array(u)[0]),f=function(){function e(){}return e.parseScriptData=function(t,i,n){var r={};try{var o=e.parseValue(t,i,n),a=e.parseValue(t,i+o.size,n-o.size);r[o.data]=a.data}catch(e){s.Z.e("AMF",e.toString())}return r},e.parseObject=function(t,i,n){if(n<3)throw new d.rT("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,n),s=e.parseValue(t,i+r.size,n-r.size),o=s.objectEnd;return{data:{name:r.data,value:s.data},size:r.size+s.size,objectEnd:o}},e.parseVariable=function(t,i,n){return e.parseObject(t,i,n)},e.parseString=function(e,t,i){if(i<2)throw new d.rT("Data not enough when parse String");var n=new DataView(e,t,i).getUint16(0,!c);return{data:n>0?l(new Uint8Array(e,t+2,n)):"",size:2+n}},e.parseLongString=function(e,t,i){if(i<4)throw new d.rT("Data not enough when parse LongString");var n=new DataView(e,t,i).getUint32(0,!c);return{data:n>0?l(new Uint8Array(e,t+4,n)):"",size:4+n}},e.parseDate=function(e,t,i){if(i<10)throw new d.rT("Data size invalid when parse Date");var n=new DataView(e,t,i),r=n.getFloat64(0,!c),s=n.getInt16(8,!c);return{data:new Date(r+=60*s*1e3),size:10}},e.parseValue=function(t,i,n){if(n<1)throw new d.rT("Data not enough when parse Value");var r,o=new DataView(t,i,n),a=1,h=o.getUint8(0),u=!1;try{switch(h){case 0:r=o.getFloat64(1,!c),a+=8;break;case 1:r=!!o.getUint8(1),a+=1;break;case 2:var l=e.parseString(t,i+1,n-1);r=l.data,a+=l.size;break;case 3:r={};var f=0;for(9==(16777215&o.getUint32(n-4,!c))&&(f=3);a32)throw new d.OC("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var i=this._current_word_bits_left?this._current_word:0;i>>>=32-this._current_word_bits_left;var n=e-this._current_word_bits_left;this._fillCurrentWord();var r=Math.min(n,this._current_word_bits_left),s=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,i=i<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}(),p=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,n=new Uint8Array(i),r=0,s=0;s=2&&3===t[s]&&0===t[s-1]&&0===t[s-2]||(n[r]=t[s],r++);return new Uint8Array(n.buffer,0,r)},e.parseSPS=function(t){var i=e._ebsp2rbsp(t),n=new _(i);n.readByte();var r=n.readByte();n.readByte();var s=n.readByte();n.readUEG();var o=e.getProfileString(r),a=e.getLevelString(s),h=1,u=420,l=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(3===(h=n.readUEG())&&n.readBits(1),h<=3&&(u=[0,420,422,444][h]),l=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBool()))for(var d=3!==h?8:12,c=0;c0&&k<16?(L=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][k-1],R=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][k-1]):255===k&&(L=n.readByte()<<8|n.readByte(),R=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){var D=n.readBits(32),I=n.readBits(32);O=n.readBool(),w=(T=I)/(C=2*D)}}var M=1;1===L&&1===R||(M=L/R);var B=0,x=0;0===h?(B=1,x=2-y):(B=3===h?1:2,x=(1===h?2:1)*(2-y));var P=16*(g+1),U=16*(v+1)*(2-y);P-=(b+E)*B,U-=(S+A)*x;var N=Math.ceil(P*M);return n.destroy(),n=null,{profile_string:o,level_string:a,bit_depth:l,ref_frames:m,chroma_format:u,chroma_format_string:e.getChromaFormatString(u),frame_rate:{fixed:O,fps:w,fps_den:C,fps_num:T},sar_ratio:{width:L,height:R},codec_size:{width:P,height:U},present_size:{width:N,height:U}}},e._skipScalingList=function(e,t){for(var i=8,n=8,r=0;r>>2!=0,o=0!=(1&t[4]),a=(n=t)[r=5]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3];return a<9?i:{match:!0,consumed:a,dataOffset:a,hasAudioTrack:s,hasVideoTrack:o}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new a.Z},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,i){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new d.rT("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var n=0,r=this._littleEndian;if(0===i){if(!(t.byteLength>13))return 0;n=e.probe(t).dataOffset}this._firstParse&&(this._firstParse=!1,i+n!==this._dataOffset&&s.Z.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==(o=new DataView(t,n)).getUint32(0,!r)&&s.Z.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4);for(;nt.byteLength)break;var a=o.getUint8(0),h=16777215&o.getUint32(0,!r);if(n+11+h+4>t.byteLength)break;if(8===a||9===a||18===a){var u=o.getUint8(4),l=o.getUint8(5),c=o.getUint8(6)|l<<8|u<<16|o.getUint8(7)<<24;0!==(16777215&o.getUint32(7,!r))&&s.Z.w(this.TAG,"Meet tag which has StreamID != 0!");var f=n+11;switch(a){case 8:this._parseAudioData(t,f,h,c);break;case 9:this._parseVideoData(t,f,h,c,i+n);break;case 18:this._parseScriptData(t,f,h)}var _=o.getUint32(11+h,!r);_!==11+h&&s.Z.w(this.TAG,"Invalid PrevTagSize "+_),n+=11+h+4}else s.Z.w(this.TAG,"Unsupported tag type "+a+", skipped"),n+=11+h+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n},e.prototype._parseScriptData=function(e,t,i){var n=f.parseScriptData(e,t,i);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!=typeof n.onMetaData)return void s.Z.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&s.Z.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var r=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},r)),"boolean"==typeof r.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=r.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof r.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=r.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof r.audiodatarate&&(this._mediaInfo.audioDataRate=r.audiodatarate),"number"==typeof r.videodatarate&&(this._mediaInfo.videoDataRate=r.videodatarate),"number"==typeof r.width&&(this._mediaInfo.width=r.width),"number"==typeof r.height&&(this._mediaInfo.height=r.height),"number"==typeof r.duration){if(!this._durationOverrided){var o=Math.floor(r.duration*this._timescale);this._duration=o,this._mediaInfo.duration=o}}else this._mediaInfo.duration=0;if("number"==typeof r.framerate){var a=Math.floor(1e3*r.framerate);if(a>0){var h=a/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=h,this._referenceFrameRate.fps_num=a,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=h}}if("object"==typeof r.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var u=r.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(u),r.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=r,s.Z.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],i=[],n=1;n>>4;if(2===o||10===o){var a=0,h=(12&r)>>>2;if(h>=0&&h<=4){a=this._flvSoundRateTable[h];var u=1&r,l=this._audioMetadata,d=this._audioTrack;if(l||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(l=this._audioMetadata={}).type="audio",l.id=d.id,l.timescale=this._timescale,l.duration=this._duration,l.audioSampleRate=a,l.channelCount=0===u?1:2),10===o){var c=this._parseAACAudioData(e,t+1,i-1);if(null==c)return;if(0===c.packetType){l.config&&s.Z.w(this.TAG,"Found another AudioSpecificConfig!");var f=c.data;l.audioSampleRate=f.samplingRate,l.channelCount=f.channelCount,l.codec=f.codec,l.originalCodec=f.originalCodec,l.config=f.config,l.refSampleDuration=1024/l.audioSampleRate*l.timescale,s.Z.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",l),(g=this._mediaInfo).audioCodec=l.originalCodec,g.audioSampleRate=l.audioSampleRate,g.audioChannelCount=l.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===c.packetType){var _=this._timestampBase+n,p={unit:c.data,length:c.data.byteLength,dts:_,pts:_};d.samples.push(p),d.length+=c.data.length}else s.Z.e(this.TAG,"Flv: Unsupported AAC data type "+c.packetType)}else if(2===o){if(!l.codec){var g;if(null==(f=this._parseMP3AudioData(e,t+1,i-1,!0)))return;l.audioSampleRate=f.samplingRate,l.channelCount=f.channelCount,l.codec=f.codec,l.originalCodec=f.originalCodec,l.refSampleDuration=1152/l.audioSampleRate*l.timescale,s.Z.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",l),(g=this._mediaInfo).audioCodec=l.codec,g.audioSampleRate=l.audioSampleRate,g.audioChannelCount=l.channelCount,g.audioDataRate=f.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var v=this._parseMP3AudioData(e,t+1,i-1,!1);if(null==v)return;_=this._timestampBase+n;var y={unit:v,length:v.byteLength,dts:_,pts:_};d.samples.push(y),d.length+=v.length}}else this._onError(m.Z.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+h)}else this._onError(m.Z.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+o)}},e.prototype._parseAACAudioData=function(e,t,i){if(!(i<=1)){var n={},r=new Uint8Array(e,t,i);return n.packetType=r[0],0===r[0]?n.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):n.data=r.subarray(1),n}s.Z.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,i){var n,r,s=new Uint8Array(e,t,i),o=null,a=0,h=null;if(a=n=s[0]>>>3,(r=(7&s[0])<<1|s[1]>>>7)<0||r>=this._mpegSamplingRates.length)this._onError(m.Z.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var u=this._mpegSamplingRates[r],l=(120&s[1])>>>3;if(!(l<0||l>=8)){5===a&&(h=(7&s[1])<<1|s[2]>>>7,(124&s[2])>>>2);var d=self.navigator.userAgent.toLowerCase();return-1!==d.indexOf("firefox")?r>=6?(a=5,o=new Array(4),h=r-3):(a=2,o=new Array(2),h=r):-1!==d.indexOf("android")?(a=2,o=new Array(2),h=r):(a=5,h=r,o=new Array(4),r>=6?h=r-3:1===l&&(a=2,o=new Array(2),h=r)),o[0]=a<<3,o[0]|=(15&r)>>>1,o[1]=(15&r)<<7,o[1]|=(15&l)<<3,5===a&&(o[1]|=(15&h)>>>1,o[2]=(1&h)<<7,o[2]|=8,o[3]=0),{config:o,samplingRate:u,channelCount:l,codec:"mp4a.40."+a,originalCodec:"mp4a.40."+n}}this._onError(m.Z.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,i,n){if(!(i<4)){this._littleEndian;var r=new Uint8Array(e,t,i),o=null;if(n){if(255!==r[0])return;var a=r[1]>>>3&3,h=(6&r[1])>>1,u=(240&r[2])>>>4,l=(12&r[2])>>>2,d=3!==(r[3]>>>6&3)?2:1,c=0,f=0;switch(a){case 0:c=this._mpegAudioV25SampleRateTable[l];break;case 2:c=this._mpegAudioV20SampleRateTable[l];break;case 3:c=this._mpegAudioV10SampleRateTable[l]}switch(h){case 1:34,u>>4,h=15&o;7===h?this._parseAVCVideoPacket(e,t+1,i-1,n,r,a):this._onError(m.Z.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+h)}},e.prototype._parseAVCVideoPacket=function(e,t,i,n,r,o){if(i<4)s.Z.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var a=this._littleEndian,h=new DataView(e,t,i),u=h.getUint8(0),l=(16777215&h.getUint32(0,!a))<<8>>8;if(0===u)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===u)this._parseAVCVideoData(e,t+4,i-4,n,r,o,l);else if(2!==u)return void this._onError(m.Z.FORMAT_ERROR,"Flv: Invalid video packet type "+u)}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,i){if(i<7)s.Z.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var n=this._videoMetadata,r=this._videoTrack,o=this._littleEndian,a=new DataView(e,t,i);n?void 0!==n.avcc&&s.Z.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(n=this._videoMetadata={}).type="video",n.id=r.id,n.timescale=this._timescale,n.duration=this._duration);var h=a.getUint8(0),u=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1===h&&0!==u)if(this._naluLengthSize=1+(3&a.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var l=31&a.getUint8(5);if(0!==l){l>1&&s.Z.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+l);for(var d=6,c=0;c1&&s.Z.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+R),d++;for(c=0;c=i){s.Z.w(this.TAG,"Malformed Nalu near timestamp "+_+", offset = "+c+", dataSize = "+i);break}var m=u.getUint32(c,!h);if(3===f&&(m>>>=8),m>i-f)return void s.Z.w(this.TAG,"Malformed Nalus near timestamp "+_+", NaluSize > DataSize!");var g=31&u.getUint8(c+f);5===g&&(p=!0);var v=new Uint8Array(e,t+c,f+m),y={type:g,data:v};l.push(y),d+=v.byteLength,c+=f+m}if(l.length){var b=this._videoTrack,E={units:l,length:d,isKeyframe:p,dts:_,cts:a,pts:_+a};p&&(E.fileposition=r),b.samples.push(E),b.length+=d}},e}(),v=function(){function e(){}return e.init=function(){for(var t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=e.constants={};i.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),i.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),i.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSC=i.STCO=i.STTS,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),i.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,i=null,n=Array.prototype.slice.call(arguments,1),r=n.length,s=0;s>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);var o=8;for(s=0;s>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var i=t.id,n=t.duration,r=t.presentWidth,s=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var i=t.timescale,n=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))},e.hdlr=function(t){var i=null;return i="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,i)},e.minf=function(t){var i=null;return i="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types[".mp3"],r)},e.mp4a=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types.mp4a,r,e.esds(t))},e.esds=function(t){var i=t.config||[],n=i.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)},e.avc1=function(t){var i=t.avcc,n=t.codecWidth,r=t.codecHeight,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>>8&255,255&n,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,s,e.box(e.types.avcC,i))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var i=t.id,n=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,n)},e.moof=function(t,i){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,i))},e.mfhd=function(t){var i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,i)},e.traf=function(t,i){var n=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),s=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),o=e.sdtp(t),a=e.trun(t,o.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,s,a,o)},e.sdtp=function(t){for(var i=t.samples||[],n=i.length,r=new Uint8Array(4+n),s=0;s>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var a=0;a>>24&255,h>>>16&255,h>>>8&255,255&h,u>>>24&255,u>>>16&255,u>>>8&255,255&u,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.isNonSync,0,0,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*a)}return e.box(e.types.trun,o)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();v.init();var y=v,b=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},e}(),E=i(51),S=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new E.J1("audio"),this._videoSegmentInfoList=new E.J1("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!o.Z.chrome||!(o.Z.version.major<50||50===o.Z.version.major&&o.Z.version.build<2661)),this._fillSilentAfterSeek=o.Z.msedge||o.Z.msie,this._mp3UseMpegAudio=!o.Z.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new d.rT("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var i=null,n="mp4",r=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(n="mpeg",r="",i=new Uint8Array):i=y.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=y.generateInitSegment(t)}if(!this._onInitSegment)throw new d.rT("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:r,container:e+"/"+n,mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);var n={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(n.samples.push(t),n.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(n,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var i,n=e,r=n.samples,a=void 0,h=-1,u=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,d=this._dtsBaseInited&&void 0===this._audioNextDts,c=!1;if(r&&0!==r.length&&(1!==r.length||t)){var f=0,_=null,p=0;l?(f=0,p=n.length):(f=8,p=8+n.length);var m=null;if(r.length>1&&(p-=(m=r.pop()).length),null!=this._audioStashedLastSample){var g=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(g),p+=g.length}null!=m&&(this._audioStashedLastSample=m);var v=r[0].dts-this._dtsBase;if(this._audioNextDts)a=v-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())a=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(c=!0);else{var S=this._audioSegmentInfoList.getLastSampleBefore(v);if(null!=S){var A=v-(S.originalDts+S.duration);A<=3&&(A=0),a=v-(S.dts+S.duration+A)}else a=0}if(c){var L=v-a,R=this._videoSegmentInfoList.getLastSegmentBefore(v);if(null!=R&&R.beginDts=3*u&&this._fillAudioTimestampGap&&!o.Z.safari){I=!0;var P,U=Math.floor(a/u);s.Z.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\noriginalDts: "+D+" ms, curRefDts: "+x+" ms, dtsCorrection: "+Math.round(a)+" ms, generate: "+U+" frames"),w=Math.floor(x),B=Math.floor(x+u)-w,null==(P=b.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount))&&(s.Z.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),P=k),M=[];for(var N=0;N=1?T[T.length-1].duration:Math.floor(u);this._audioNextDts=w+B}-1===h&&(h=w),T.push({dts:w,pts:w,cts:0,unit:g.unit,size:g.unit.byteLength,duration:B,originalDts:D,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),I&&T.push.apply(T,M)}}if(0===T.length)return n.samples=[],void(n.length=0);l?_=new Uint8Array(p):((_=new Uint8Array(p))[0]=p>>>24&255,_[1]=p>>>16&255,_[2]=p>>>8&255,_[3]=255&p,_.set(y.types.mdat,4));for(C=0;C1&&(d-=(c=s.pop()).length),null!=this._videoStashedLastSample){var f=this._videoStashedLastSample;this._videoStashedLastSample=null,s.unshift(f),d+=f.length}null!=c&&(this._videoStashedLastSample=c);var _=s[0].dts-this._dtsBase;if(this._videoNextDts)o=_-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())o=0;else{var p=this._videoSegmentInfoList.getLastSampleBefore(_);if(null!=p){var m=_-(p.originalDts+p.duration);m<=3&&(m=0),o=_-(p.dts+p.duration+m)}else o=0}for(var g=new E.Yy,v=[],b=0;b=1?v[v.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(A){var T=new E.Wk(L,w,O,f.dts,!0);T.fileposition=f.fileposition,g.appendSyncPoint(T)}v.push({dts:L,pts:w,cts:R,units:f.units,size:f.length,isKeyframe:A,duration:O,originalDts:S,flags:{isLeading:0,dependsOn:A?2:1,isDependedOn:A?1:0,hasRedundancy:0,isNonSync:A?0:1}})}(l=new Uint8Array(d))[0]=d>>>24&255,l[1]=d>>>16&255,l[2]=d>>>8&255,l[3]=255&d,l.set(y.types.mdat,4);for(b=0;b0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=g.probe(e)).match){this._demuxer=new g(n,this._config),this._remuxer||(this._remuxer=new S(this._config));var o=this._mediaDataSource;null==o.duration||isNaN(o.duration)||(this._demuxer.overridedDuration=o.duration),"boolean"==typeof o.hasAudio&&(this._demuxer.overridedHasAudio=o.hasAudio),"boolean"==typeof o.hasVideo&&(this._demuxer.overridedHasVideo=o.hasVideo),this._demuxer.timestampBase=o.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else n=null,s.Z.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then((function(){i._internalAbort()})),this._emitter.emit(L.Z.DEMUX_ERROR,m.Z.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,a.Z.prototype));var i=Object.assign({},e);Object.setPrototypeOf(i,a.Z.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(L.Z.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(L.Z.SCRIPTDATA_ARRIVED,e)},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e+1;t0&&i[0].originalDts===n&&(n=i[0].pts),this._emitter.emit(L.Z.RECOMMEND_SEEKPOINT,n)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(L.Z.MEDIA_INFO,i)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(L.Z.STATISTICS_INFO,e)},e}()},257:function(e,t){"use strict";t.Z={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"}},82:function(e,t,i){"use strict";i(846),i(219),i(949),i(257)},600:function(e,t){"use strict";t.Z={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},60:function(e,t,i){"use strict";i.d(t,{default:function(){return D}});var n=i(219),r=i(191),s={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function o(){return Object.assign({},s)}var a=function(){function e(){}return e.supportMSEH264Playback=function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')},e.supportNetworkStreamIO=function(){var e=new r.Z({},o()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t},e.getNetworkLoaderTypeName=function(){var e=new r.Z({},o()),t=e.loaderType;return e.destroy(),t},e.supportNativeMediaPlayback=function(t){null==e.videoElement&&(e.videoElement=window.document.createElement("video"));var i=e.videoElement.canPlayType(t);return"probably"===i||"maybe"==i},e.getFeatureList=function(){var t={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return t.mseFlvPlayback=e.supportMSEH264Playback(),t.networkStreamIO=e.supportNetworkStreamIO(),t.networkLoaderName=e.getNetworkLoaderTypeName(),t.mseLiveFlvPlayback=t.mseFlvPlayback&&t.networkStreamIO,t.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),t.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),t.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),t},e}(),h=i(939),u=i(716),l=i.n(u),d=i(300),c=i(538),f={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"},_=i(397),p=i.n(_),m=i(846),g=i(949),v=i(257),y=i(118),b=function(){function e(e,t){if(this.TAG="Transmuxer",this._emitter=new(l()),t.enableWorker&&"undefined"!=typeof Worker)try{this._worker=p()(82),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},m.Z.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:m.Z.getConfig()})}catch(i){d.Z.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new g.Z(e,t)}else this._controller=new g.Z(e,t);if(this._controller){var i=this._controller;i.on(v.Z.IO_ERROR,this._onIOError.bind(this)),i.on(v.Z.DEMUX_ERROR,this._onDemuxError.bind(this)),i.on(v.Z.INIT_SEGMENT,this._onInitSegment.bind(this)),i.on(v.Z.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),i.on(v.Z.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),i.on(v.Z.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),i.on(v.Z.MEDIA_INFO,this._onMediaInfo.bind(this)),i.on(v.Z.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),i.on(v.Z.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),i.on(v.Z.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),i.on(v.Z.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return e.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),m.Z.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.hasWorker=function(){return null!=this._worker},e.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},e.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},e.prototype.seek=function(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)},e.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},e.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},e.prototype._onInitSegment=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(v.Z.INIT_SEGMENT,e,t)}))},e.prototype._onMediaSegment=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(v.Z.MEDIA_SEGMENT,e,t)}))},e.prototype._onLoadingComplete=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(v.Z.LOADING_COMPLETE)}))},e.prototype._onRecoveredEarlyEof=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(v.Z.RECOVERED_EARLY_EOF)}))},e.prototype._onMediaInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(v.Z.MEDIA_INFO,e)}))},e.prototype._onMetaDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(v.Z.METADATA_ARRIVED,e)}))},e.prototype._onScriptDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(v.Z.SCRIPTDATA_ARRIVED,e)}))},e.prototype._onStatisticsInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(v.Z.STATISTICS_INFO,e)}))},e.prototype._onIOError=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(v.Z.IO_ERROR,e,t)}))},e.prototype._onDemuxError=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(v.Z.DEMUX_ERROR,e,t)}))},e.prototype._onRecommendSeekpoint=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(v.Z.RECOMMEND_SEEKPOINT,e)}))},e.prototype._onLoggingConfigChanged=function(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})},e.prototype._onWorkerMessage=function(e){var t=e.data,i=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case v.Z.INIT_SEGMENT:case v.Z.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case v.Z.LOADING_COMPLETE:case v.Z.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case v.Z.MEDIA_INFO:Object.setPrototypeOf(i,y.Z.prototype),this._emitter.emit(t.msg,i);break;case v.Z.METADATA_ARRIVED:case v.Z.SCRIPTDATA_ARRIVED:case v.Z.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case v.Z.IO_ERROR:case v.Z.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case v.Z.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":d.Z.emitter.emit("log",i.type,i.logcat)}},e}(),E={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"},S=i(51),A=i(29),L=function(){function e(e){this.TAG="MSEController",this._config=e,this._emitter=new(l()),this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new S.Vn}return e.prototype.destroy=function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaSource)throw new A.rT("MediaSource has been attached to an HTMLMediaElement!");var t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL},e.prototype.detachMediaElement=function(){if(this._mediaSource){var e=this._mediaSource;for(var t in this._sourceBuffers){var i=this._pendingSegments[t];i.splice(0,i.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;var n=this._sourceBuffers[t];if(n){if("closed"!==e.readyState){try{e.removeSourceBuffer(n)}catch(e){d.Z.e(this.TAG,e.message)}n.removeEventListener("error",this.e.onSourceBufferError),n.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){d.Z.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},e.prototype.appendInitSegment=function(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);var i=e,n=""+i.container;i.codec&&i.codec.length>0&&(n+=";codecs="+i.codec);var r=!1;if(d.Z.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[i.type]=i,n!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])d.Z.v(this.TAG,"Notice: "+i.type+" mimeType changed, origin: "+this._mimeTypes[i.type]+", target: "+n);else{r=!0;try{var s=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(n);s.addEventListener("error",this.e.onSourceBufferError),s.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return d.Z.e(this.TAG,e.message),void this._emitter.emit(E.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=n}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),c.Z.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var i=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{i.abort()}catch(e){d.Z.e(this.TAG,e.message)}this._idrList.clear();var n=this._pendingSegments[t];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(var r=0;r=1&&e-n.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){for(var n=i.buffered,r=!1,s=0;s=this._config.autoCleanupMaxBackwardDuration){r=!0;var h=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:o,end:h})}}else a0&&(isNaN(t)||i>t)&&(d.Z.v(this.TAG,"Update MediaSource duration from "+t+" to "+i),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];i.length&&!t.updating;){var n=i.shift();t.remove(n.start,n.end)}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var i=e[t].shift();if(i.timestampOffset){var n=this._sourceBuffers[t].timestampOffset,r=i.timestampOffset/1e3;Math.abs(n-r)>.1&&(d.Z.v(this.TAG,"Update MPEG audio timestampOffset from "+n+" to "+r),this._sourceBuffers[t].timestampOffset=r),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1,"video"===t&&i.hasOwnProperty("info")&&this._idrList.appendArray(i.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(E.BUFFER_FULL),this._isBufferFull=!0):(d.Z.e(this.TAG,e.message),this._emitter.emit(E.ERROR,{code:e.code,msg:e.message}))}}},e.prototype._onSourceOpen=function(){if(d.Z.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(E.SOURCE_OPEN)},e.prototype._onSourceEnded=function(){d.Z.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){d.Z.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(E.UPDATE_END)},e.prototype._onSourceBufferError=function(e){d.Z.e(this.TAG,"SourceBuffer Error: "+e)},e}(),R=i(600),w={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},O={NETWORK_EXCEPTION:h.nm.EXCEPTION,NETWORK_STATUS_CODE_INVALID:h.nm.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:h.nm.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:h.nm.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:R.Z.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:R.Z.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:R.Z.CODEC_UNSUPPORTED},T=function(){function e(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(l()),this._config=o(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new A.OC("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var i=c.Z.chrome&&(c.Z.version.major<50||50===c.Z.version.major&&c.Z.version.build<2661);this._alwaysSeekKeyframe=!!(i||c.Z.msedge||c.Z.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;e===f.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){i._emitter.emit(f.MEDIA_INFO,i.mediaInfo)})):e===f.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){i._emitter.emit(f.STATISTICS_INFO,i.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new L(this._config),this._msectl.on(E.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(E.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(E.SOURCE_OPEN,(function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())})),this._msectl.on(E.ERROR,(function(e){t._emitter.emit(f.ERROR,w.MEDIA_ERROR,O.MEDIA_MSE_ERROR,e)})),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new A.rT("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new A.rT("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new b(this._mediaDataSource,this._config),this._transmuxer.on(v.Z.INIT_SEGMENT,(function(t,i){e._msectl.appendInitSegment(i)})),this._transmuxer.on(v.Z.MEDIA_SEGMENT,(function(t,i){if(e._msectl.appendMediaSegment(i),e._config.lazyLoad&&!e._config.isLive){var n=e._mediaElement.currentTime;i.info.endDts>=1e3*(n+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(d.Z.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(v.Z.LOADING_COMPLETE,(function(){e._msectl.endOfStream(),e._emitter.emit(f.LOADING_COMPLETE)})),this._transmuxer.on(v.Z.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(f.RECOVERED_EARLY_EOF)})),this._transmuxer.on(v.Z.IO_ERROR,(function(t,i){e._emitter.emit(f.ERROR,w.NETWORK_ERROR,t,i)})),this._transmuxer.on(v.Z.DEMUX_ERROR,(function(t,i){e._emitter.emit(f.ERROR,w.MEDIA_ERROR,t,{code:-1,msg:i})})),this._transmuxer.on(v.Z.MEDIA_INFO,(function(t){e._mediaInfo=t,e._emitter.emit(f.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(v.Z.METADATA_ARRIVED,(function(t){e._emitter.emit(f.METADATA_ARRIVED,t)})),this._transmuxer.on(v.Z.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(f.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(v.Z.STATISTICS_INFO,(function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(f.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(v.Z.RECOMMEND_SEEKPOINT,(function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)})),this._transmuxer.open()))},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),e.prototype._fillStatisticsInfo=function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e},e.prototype._onmseUpdateEnd=function(){if(this._config.lazyLoad&&!this._config.isLive){for(var e=this._mediaElement.buffered,t=this._mediaElement.currentTime,i=0,n=0;n=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(d.Z.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){d.Z.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1,n=0;n=r&&e=s-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(d.Z.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},e.prototype._isTimepointBuffered=function(e){for(var t=this._mediaElement.buffered,i=0;i=n&&e0){var r=this._mediaElement.buffered.start(0);(r<1&&e0&&t.currentTime0){var n=i.start(0);if(n<1&&t0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(f.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(f.STATISTICS_INFO,this.statisticsInfo)},e}();n.Z.install();var k={createPlayer:function(e,t){var i=e;if(null==i||"object"!=typeof i)throw new A.OC("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new A.OC("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"flv":return new T(i,t);default:return new C(i,t)}},isSupported:function(){return a.supportMSEH264Playback()},getFeatureList:function(){return a.getFeatureList()}};k.BaseLoader=h.fp,k.LoaderStatus=h.GM,k.LoaderErrors=h.nm,k.Events=f,k.ErrorTypes=w,k.ErrorDetails=O,k.FlvPlayer=T,k.NativePlayer=C,k.LoggingControl=m.Z,Object.defineProperty(k,"version",{enumerable:!0,get:function(){return"1.6.2"}});var D=k},324:function(e,t,i){e.exports=i(60).default},191:function(e,t,i){"use strict";i.d(t,{Z:function(){return y}});var n,r=i(300),s=function(){function e(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}(),o=i(939),a=i(538),h=i(29),u=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),l=function(e){function t(t,i){var n=e.call(this,"fetch-stream-loader")||this;return n.TAG="FetchStreamLoader",n._seekHandler=t,n._config=i,n._needStash=!0,n._requestAbort=!1,n._contentLength=null,n._receivedLength=0,n}return u(t,e),t.isSupported=function(){try{var e=a.Z.msedge&&a.Z.version.minor>=15048,t=!a.Z.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var i=this;this._dataSource=e,this._range=t;var n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);var r=this._seekHandler.getConfig(n,t),s=new self.Headers;if("object"==typeof r.headers){var a=r.headers;for(var u in a)a.hasOwnProperty(u)&&s.append(u,a[u])}var l={method:"GET",headers:s,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(var u in this._config.headers)s.append(u,this._config.headers[u]);!1===e.cors&&(l.mode="same-origin"),e.withCredentials&&(l.credentials="include"),e.referrerPolicy&&(l.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,l.signal=this._abortController.signal),this._status=o.GM.kConnecting,self.fetch(r.url,l).then((function(e){if(i._requestAbort)return i._status=o.GM.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&i._onURLRedirect){var t=i._seekHandler.removeURLParameters(e.url);i._onURLRedirect(t)}var n=e.headers.get("Content-Length");return null!=n&&(i._contentLength=parseInt(n),0!==i._contentLength&&i._onContentLengthKnown&&i._onContentLengthKnown(i._contentLength)),i._pump.call(i,e.body.getReader())}if(i._status=o.GM.kError,!i._onError)throw new h.OZ("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);i._onError(o.nm.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!i._abortController||!i._abortController.signal.aborted){if(i._status=o.GM.kError,!i._onError)throw e;i._onError(o.nm.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==o.GM.kBuffering||!a.Z.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(i){if(i.done)if(null!==t._contentLength&&t._receivedLength299)){if(this._status=o.GM.kError,!this._onError)throw new h.OZ("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(o.nm.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=o.GM.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==o.GM.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==o.GM.kError&&(this._status=o.GM.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=o.GM.kError;var t=0,i=null;if(this._contentLength&&e.loaded=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var i=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?i=this._currentRedirectedURL:null!=e.redirectedURL&&(i=e.redirectedURL));var n=this._seekHandler.getConfig(i,t);this._currentRequestURL=n.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",n.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof n.headers){var s=n.headers;for(var o in s)s.hasOwnProperty(o)&&r.setRequestHeader(o,s[o])}if("object"==typeof this._config.headers){s=this._config.headers;for(var o in s)s.hasOwnProperty(o)&&r.setRequestHeader(o,s[o])}r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=o.GM.kComplete},t.prototype._internalAbort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=o.GM.kBuffering}else{if(this._status=o.GM.kError,!this._onError)throw new h.OZ("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(o.nm.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==o.GM.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var n=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(n)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,i=t.length-1,n=0,r=0,s=i;if(e=t[n]&&e=3&&(t=this._speedSampler.currentKBps)),0!==t){var i=this._normalizeSpeed(t);this._currentSpeedNormalized!==i&&(this._currentSpeedNormalized=i,this._currentChunkSizeKB=i)}var n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;var s=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength0)for(var s=i.split("&"),o=0;o0;a[0]!==this._startName&&a[0]!==this._endName&&(h&&(r+="&"),r+=s[o])}return 0===r.length?t:t+"?"+r},e}(),y=function(){function e(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=393216,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new s,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return e.prototype.destroy=function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===_?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new g(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new v(t,i)}else{if("custom"!==e.seekType)throw new h.OC("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new h.OC("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=m;else if(l.isSupported())this._loaderClass=l;else if(c.isSupported())this._loaderClass=c;else{if(!_.isSupported())throw new h.OZ("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=_}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!=typeof e||0===e.length)throw new h.OC("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){for(var t=this._stashSize;t+10485760){var n=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(n,0)}this._stashBuffer=i,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,i=t.length-1,n=0,r=0,s=i;if(e=t[n]&&e=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var i=1024*t+1048576;this._bufferSize0){var s=this._stashBuffer.slice(0,this._stashUsed);if((u=this._dispatchChunks(s,this._stashByteStart))0){l=new Uint8Array(s,u);a.set(l,0),this._stashUsed=l.byteLength,this._stashByteStart+=u}}else this._stashUsed=0,this._stashByteStart+=u;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),a=new Uint8Array(this._stashBuffer,0,this._bufferSize)),a.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{if((u=this._dispatchChunks(e,t))this._bufferSize&&(this._expandBuffer(o),a=new Uint8Array(this._stashBuffer,0,this._bufferSize)),a.set(new Uint8Array(e,u),0),this._stashUsed+=o,this._stashByteStart=t+u}}else if(0===this._stashUsed){var o;if((u=this._dispatchChunks(e,t))this._bufferSize&&this._expandBuffer(o),(a=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e,u),0),this._stashUsed+=o,this._stashByteStart=t+u}else{var a,u;if(this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength),(a=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength,(u=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))0){var l=new Uint8Array(this._stashBuffer,u);a.set(l,0)}this._stashUsed-=u,this._stashByteStart+=u}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),n=t.byteLength-i;if(i0){var s=new Uint8Array(this._stashBuffer,0,this._bufferSize),o=new Uint8Array(t,i);s.set(o,0),this._stashUsed=o.byteLength,this._stashByteStart+=i}return 0}r.Z.w(this.TAG,n+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,n}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(r.Z.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=o.nm.UNRECOVERABLE_EARLY_EOF),e){case o.nm.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=this._currentRange.to+1;return void(i=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],n=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:n[0]||""},s={};if(r.browser){s[r.browser]=!0;var o=r.majorVersion.split(".");s.version={major:parseInt(r.majorVersion,10),string:r.version},o.length>1&&(s.version.minor=parseInt(o[1],10)),o.length>2&&(s.version.build=parseInt(o[2],10))}if(r.platform&&(s[r.platform]=!0),(s.chrome||s.opr||s.safari)&&(s.webkit=!0),s.rv||s.iemobile){s.rv&&delete s.rv;var a="msie";r.browser=a,s.msie=!0}if(s.edge){delete s.edge;var h="msedge";r.browser=h,s.msedge=!0}if(s.opr){var u="opera";r.browser=u,s.opera=!0}if(s.safari&&s.android){var l="android";r.browser=l,s.android=!0}for(var d in s.name=r.browser,s.platform=r.platform,i)i.hasOwnProperty(d)&&delete i[d];Object.assign(i,s)}(),t.Z=i},29:function(e,t,i){"use strict";i.d(t,{OZ:function(){return s},rT:function(){return o},OC:function(){return a},do:function(){return h}});var n,r=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),o=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(s),a=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(s),h=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(s)},300:function(e,t,i){"use strict";var n=i(716),r=i.n(n),s=function(){function e(){}return e.e=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",n),e.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))},e.i=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",n),e.ENABLE_INFO&&(console.info?console.info(n):console.log(n))},e.w=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",n),e.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))},e.d=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",n),e.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))},e.v=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",n),e.ENABLE_VERBOSE&&console.log(n)},e}();s.GLOBAL_TAG="flv.js",s.FORCE_GLOBAL_TAG=!1,s.ENABLE_ERROR=!0,s.ENABLE_INFO=!0,s.ENABLE_WARN=!0,s.ENABLE_DEBUG=!0,s.ENABLE_VERBOSE=!0,s.ENABLE_CALLBACK=!1,s.emitter=new(r()),t.Z=s},846:function(e,t,i){"use strict";var n=i(716),r=i.n(n),s=i(300),o=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return s.Z.FORCE_GLOBAL_TAG},set:function(t){s.Z.FORCE_GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return s.Z.GLOBAL_TAG},set:function(t){s.Z.GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return s.Z.ENABLE_VERBOSE&&s.Z.ENABLE_DEBUG&&s.Z.ENABLE_INFO&&s.Z.ENABLE_WARN&&s.Z.ENABLE_ERROR},set:function(t){s.Z.ENABLE_VERBOSE=t,s.Z.ENABLE_DEBUG=t,s.Z.ENABLE_INFO=t,s.Z.ENABLE_WARN=t,s.Z.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return s.Z.ENABLE_DEBUG},set:function(t){s.Z.ENABLE_DEBUG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableVerbose",{get:function(){return s.Z.ENABLE_VERBOSE},set:function(t){s.Z.ENABLE_VERBOSE=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return s.Z.ENABLE_INFO},set:function(t){s.Z.ENABLE_INFO=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return s.Z.ENABLE_WARN},set:function(t){s.Z.ENABLE_WARN=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return s.Z.ENABLE_ERROR},set:function(t){s.Z.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),e.getConfig=function(){return{globalTag:s.Z.GLOBAL_TAG,forceGlobalTag:s.Z.FORCE_GLOBAL_TAG,enableVerbose:s.Z.ENABLE_VERBOSE,enableDebug:s.Z.ENABLE_DEBUG,enableInfo:s.Z.ENABLE_INFO,enableWarn:s.Z.ENABLE_WARN,enableError:s.Z.ENABLE_ERROR,enableCallback:s.Z.ENABLE_CALLBACK}},e.applyConfig=function(e){s.Z.GLOBAL_TAG=e.globalTag,s.Z.FORCE_GLOBAL_TAG=e.forceGlobalTag,s.Z.ENABLE_VERBOSE=e.enableVerbose,s.Z.ENABLE_DEBUG=e.enableDebug,s.Z.ENABLE_INFO=e.enableInfo,s.Z.ENABLE_WARN=e.enableWarn,s.Z.ENABLE_ERROR=e.enableError,s.Z.ENABLE_CALLBACK=e.enableCallback},e._notifyChange=function(){var t=e.emitter;if(t.listenerCount("change")>0){var i=e.getConfig();t.emit("change",i)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){s.Z.emitter.addListener("log",t),s.Z.emitter.listenerCount("log")>0&&(s.Z.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){s.Z.emitter.removeListener("log",t),0===s.Z.emitter.listenerCount("log")&&(s.Z.ENABLE_CALLBACK=!1,e._notifyChange())},e}();o.emitter=new(r()),t.Z=o},219:function(e,t,i){"use strict";var n=function(){function e(){}return e.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i {
+ model_select_datas.push(option.name);
+ modelMap[option.name] = option.ID;
+ });
+ set_select_data("modelSelect",model_select_datas);
+
+ //视频通道下拉框
+ response = await fetch('/api/channel/tree');
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ channel_datas = await response.json();
+ channel_select_datas = ["请选择"];
+ channel_datas.forEach(option => {
+ channel_select_datas.push(option.channel_name);
+ channelMap[option.channel_name] = option.ID;
+ });
+ set_select_data("channelSelect",channel_select_datas);
+
+ //查询告警数据
+ let modelName = document.getElementById('modelSelect').value;
+ let channelId = document.getElementById('channelSelect').value;
+ const startTime = document.getElementById('startTime').value;
+ const endTime = document.getElementById('endTime').value;
+ const sCount = 0; // 起始记录数从0开始
+ const eCount = 100; // 每页显示10条记录
+
+ if(modelName == "请选择"){
+ modelName = "";
+ }
+ if(channelId == "请选择"){
+ channelId = "";
+ }
+
+ // 构造请求体
+ const requestData = {
+ model_name: modelName || "", // 如果为空,则传空字符串
+ channel_id: channelId || "",
+ start_time: startTime || "",
+ end_time: endTime || "",
+ s_count: sCount,
+ e_count: eCount
+ };
+ try{
+ // 发送POST请求到后端
+ const response = await fetch('/api/warn/search_warn', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(requestData) // 将数据转为JSON字符串
+ });
+
+ // 检查响应是否成功
+ if (response.ok) {
+ const data = await response.json();
+ console.log('查询结果:', data);
+ // 在这里处理查询结果,比如更新表格显示数据
+ //updateTableWithData(data);
+ } else {
+ console.error('查询失败:', response.status);
+ }
+ } catch (error) {
+ console.error('请求出错:', error);
+ }
+
+ }catch (error) {
+ console.error('Error fetching model data:', error);
+ }
+
+ //读取报警数据并进行显示--要分页显示
+ // modelData_bak = modelData;
+ // currentPage = 1; // 重置当前页为第一页
+ // renderTable(); //刷新表格
+ // renderPagination();
+ //操作-删除,图片,视频,审核(灰)
+}
+
+//刷新表单页面数据
+function renderTable() {
+ const tableBody = document.getElementById('table-body-model');
+ tableBody.innerHTML = ''; //清空
+
+ const start = (currentPage - 1) * rowsPerPage;
+ const end = start + rowsPerPage;
+ const pageData = modelData.slice(start, end);
+ const surplus_count = rowsPerPage - pageData.length;
+
+
+ pageData.forEach((model) => {
+ const row = document.createElement('tr');
+ row.innerHTML = `
+ ${model.ID} |
+ ${model.name} |
+ ${model.version} |
+ ${model.duration_time} |
+ ${model.proportion} |
+
+
+
+
+ |
+ `;
+ tableBody.appendChild(row);
+ row.querySelector('.modify-btn').addEventListener('click', () => modifyModel(row));
+ row.querySelector('.algorithm-btn').addEventListener('click', () => configureModel(row));
+ row.querySelector('.delete-btn').addEventListener('click', () => deleteModel(row));
+ });
+}
+
+//刷新分页标签
+function renderPagination() {
+ const pagination = document.getElementById('pagination-model');
+ pagination.innerHTML = '';
+
+ const totalPages = Math.ceil(modelData.length / rowsPerPage);
+ for (let i = 1; i <= totalPages; i++) {
+ const pageItem = document.createElement('li');
+ pageItem.className = 'page-item' + (i === currentPage ? ' active' : '');
+ pageItem.innerHTML = `${i}`;
+ pageItem.addEventListener('click', (event) => {
+ event.preventDefault();
+ currentPage = i;
+ renderTable();
+ renderPagination();
+ });
+ pagination.appendChild(pageItem);
+ }
+}
\ No newline at end of file
diff --git a/web/main/templates/h264_test.html b/web/main/templates/h264_test.html
new file mode 100644
index 0000000..be7eee1
--- /dev/null
+++ b/web/main/templates/h264_test.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+ H.264 Streaming
+
+
+
+
+
+
+
+
+
diff --git a/web/main/templates/header.html b/web/main/templates/header.html
index ae593d4..2dda189 100644
--- a/web/main/templates/header.html
+++ b/web/main/templates/header.html
@@ -12,6 +12,7 @@
实时预览
通道管理
算法管理
+ 报警管理
系统管理
用户管理
diff --git a/web/main/templates/view_main.html b/web/main/templates/view_main.html
index 7300e65..7011713 100644
--- a/web/main/templates/view_main.html
+++ b/web/main/templates/view_main.html
@@ -61,14 +61,14 @@
border: 1px solid #ddd; /* 视频区域边框 */
}
- .video-area img {
- display: none; /* 初始隐藏 */
+ .video-area canvas {
+ display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
- object-fit: cover;
+ object-fit: contain;
}
.video-buttons {
@@ -91,10 +91,7 @@
min-width: 100px;
}
- .video-frame img {
- width: 100%;
- height: auto;
- }
+
#videoGrid.four .video-frame {
width: calc(50% - 10px); /* 每行4个视频框架 */
}
diff --git a/web/main/templates/warn_manager.html b/web/main/templates/warn_manager.html
new file mode 100644
index 0000000..d66f30c
--- /dev/null
+++ b/web/main/templates/warn_manager.html
@@ -0,0 +1,72 @@
+{% extends 'base.html' %}
+
+{% block title %}ZFBOX{% endblock %}
+
+{% block style %}
+ .table-container {
+ min-height: 400px; /* 设置最小高度,可以根据需要调整 */
+ }
+ /* 缩小表格行高 */
+ .table-sm th,
+ .table-sm td {
+ padding: 0.2rem; /* 调整这里的值来改变行高 */
+ }
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ 算法名称 |
+ 视频通道 |
+ 报警时间 |
+ 操作 |
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+{% block script %}
+
+{% endblock %}
\ No newline at end of file