当前位置:网站首页>大华设备播放过程中设置播放速度
大华设备播放过程中设置播放速度
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;
}边栏推荐
猜你喜欢

Sum the two numbers to find the target value

Blender stone carving

Blender model import UE, collision settings

两数之和,求目标值

Database dictionary Navicat automatic generation version

Introduction and Principle notes of UE4 material

Message mechanism -- getting to know messages and message queues for the first time

AI技术产业热点分析

pytest学习--base

Aiphacode is not a substitute for programmers, but a tool for developers
随机推荐
Solutions to a series of problems in sqoop job creation
sqoop创建job出现的一系列问题解决方法
Message mechanism -- getting to know messages and message queues for the first time
stm32和電機開發(上比特系統)
Lunix reallocates root and home space memory
Allure -- common configuration items
MYSQL关键字
Delivery mode design of Spartacus UI of SAP e-commerce cloud
[tutorial] how to make the Helpviewer help document of VisualStudio run independently
【教程】如何让VisualStudio的HelpViewer帮助文档独立运行
Notes de base sur les plans illusoires d'IA (triés en 10 000 mots)
Aiphacode is not a substitute for programmers, but a tool for developers
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
高考的意义是什么
Flink submitter
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Blender stone carving
pytest学习--base
合并有序数列
ERROR 1118 (42000): Row size too large (&gt; 8126)