当前位置:网站首页>大华设备播放过程中设置播放速度
大华设备播放过程中设置播放速度
2022-07-02 06:50:00 【微澜-】
背景
以前做了很多年的视频监控客户端,有段时间是接入大华,海康,axis,一传等sdk,在我们自己的监控系统中使用。
在网络不稳定的时候,控制播放速度总是让人头痛的事情。
设置播放速度有两种方法,一种是按照速度进行传递和计算,一种是按照帧率来计算。
因为大华的sdk默认使用帧率来计算,如果换算成速率工作量很大,出力不讨好。不如直接调用接口,设置帧率。
设置速率仅仅使用原来暂停状态,就有这样的工作量。
代码
void CDevReplay::SetPlaySpeed( DOUBLE dOldSpeed, DOUBLE dNewSpeed )
{
if(dOldSpeed == dNewSpeed)//不改变原来的速度
{
return 0;
}
if (dNewSpeed >= (-0.01) && dNewSpeed <= 0.01)
{
PauseOrContinue(1);//如果设置为0,暂停;
return;
}
PauseOrContinue(0);
if (dOldSpeed >= (-0.01) && dOldSpeed <= 0.01)
{
if (dNewSpeed < (-1.01) && dOldSpeed >= -8.00)
{
SetPlayDirection(TRUE);
while(dNewSpeed < -1.01)
{
FastPlay();
dNewSpeed += 1.0;
}
}
else if (dOldSpeed <= -0.99 && dOldSpeed >= -1.01)
{
NormalPlay();
}
else if (dNewSpeed < (-0.01) && dNewSpeed > -0.99)
{
SetPlayDirection(TRUE);
while(dNewSpeed > -1.0)
{
SlowPlay();
dNewSpeed *= 2.0;
}
}
else if ( dNewSpeed > 0.01 && dOldSpeed < 0.99)
{
while(dNewSpeed < 1.0)
{
SlowPlay();
dNewSpeed *= 2.0;
}
}
else if (dOldSpeed >= 0.99 && dOldSpeed <= 1.01)
{
NormalPlay();
}
else if (dOldSpeed > 1.01 && dOldSpeed < 8.00)
{
while(dNewSpeed > -1.01)
{
FastPlay();
dNewSpeed -= 1.0;
}
}
}
else if(dOldSpeed > 0.01)
{
...
}
else if(dOldSpeed < -0.01)
{
...
}
return ;
}
void CDevReplay::SetPlaySpeed( DOUBLE dOldSpeed, DOUBLE dNewSpeed )
{
if(dOldSpeed == dNewSpeed)//不改变原来的速度
{
return 0;
}
if (dNewSpeed >= (-0.01) && dNewSpeed <= 0.01)
{
PauseOrContinue(1);//如果设置为0,暂停;
return;
}
if (dOldSpeed >= (-0.01) && dOldSpeed <= 0.01)
{
dOldSpeed = 1.0;
}
if (dOldSpeed * dNewSpeed < 0)
{
BOOL bBackward = (dNewSpeed < 0);
SetPlayDirection(bBackward);
NormalPlay();
return;
}
PauseOrContinue(0);
LONG nRate = GetFrameRate();
DOUBLE fZoom = dNewSpeed/dOldSpeed;
nRate = nRate*fZoom;
SetFrameRate(nRate);
return ;
}
LONG CDevReplay::GetFrameRate()
{
if(0 == m_lPlayBack)return 10;
int fileframerate = 25;
int playframerate = 25;
BOOL bRet = CLIENT_GetFramePlayBack(m_lPlayBack,&fileframerate,&playframerate);
ATLASSERT(bRet);
return playframerate;
}
LONG CDevReplay::SetFrameRate( LONG nRate )
{
if(0 == m_lPlayBack)return 0;
//设置回放帧率,目前定义的范围是(1~120),超过这个范围返回FALSE
if (nRate < 1)nRate = 1;
BOOL bRet = CLIENT_SetFramePlayBack(m_lPlayBack,nRate);
ATLASSERT(bRet);
return 1;
}边栏推荐
- ERROR 1118 (42000): Row size too large (&gt; 8126)
- sqoop的表的导入
- Blender model import UE, collision settings
- Pytest learning --base
- Transport Optimization abstraction
- MYSQL环境配置
- 02-taildir source
- Excuse me, is it cost-effective to insure love life patron saint 2.0 increased lifelong life insurance? What are the advantages of this product?
- 【避坑指南】使用UGUI遇到的坑:Text组件无法首行缩进两格
- Test -- Summary of interview questions
猜你喜欢

VLAN experiment

Determine whether there are duplicate elements in the array

Aiphacode is not a substitute for programmers, but a tool for developers

Mongodb quickly get started with some simple operations of mongodb command line

pytest框架实现前后置

【避坑指南】使用UGUI遇到的坑:Text组件无法首行缩进两格

Allure -- common configuration items

13.信号量临界区保护

Is this code PHP MySQL redundant?

01 install virtual machine
随机推荐
Stm32 et développement de moteurs (système supérieur)
Windows环境MySQL8忘记密码文件解决方案
2021-10-04
[Fantasy 4] introduction and use of UMG components (under update...)
Use WinDbg to statically analyze dump files (summary of practical experience)
Translation d30 (with AC code POJ 28:sum number)
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
[unity3d] nested use layout group to make scroll view with dynamic sub object height
02-taildir source
[tutorial] how to make the Helpviewer help document of VisualStudio run independently
高考的意义是什么
【避坑指南】使用UGUI遇到的坑:Text组件无法首行缩进两格
Feature (5): how to organize information
2021-10-02
Blender ocean production
14.信号量的代码实现
Pytest learning --base
Pytest framework implements pre post
MongoDB-快速上手MongoDB命令行的一些简单操作