当前位置:网站首页>大华设备播放过程中设置播放速度
大华设备播放过程中设置播放速度
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;
}
边栏推荐
- AI技术产业热点分析
- 4.随机变量
- 2021-10-02
- [leetcode] sword finger offer 53 - I. find the number I in the sorted array
- Pytest framework implements pre post
- Message mechanism -- getting to know messages and message queues for the first time
- flume 190 INSTALL
- This article takes you to learn in detail what is fiber to home FTTH
- 2021-10-02
- SPSS做Shapiro-Wilk正态分析
猜你喜欢
MYSQL环境配置
Determine whether there are duplicate elements in the array
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
Redis set password
【MySQL】连接MySQL时出现异常:Connection must be valid and open
Applet development summary
Stm32 et développement de moteurs (système supérieur)
Postman -- use
Sum the two numbers to find the target value
Flink submitter
随机推荐
Blender volume fog
07 data import sqoop
网络通信学习
Blender海洋制作
webUI自动化学习
"Matching" is true love, a new attitude for young people to make friends
01 install virtual machine
4.随机变量
KS009基于SSH实现宠物管理系统
13.信号量临界区保护
Vscode set JSON file to format automatically after saving
Redis set password
[Lua] summary of common knowledge points (including common interview sites)
高考的意义是什么
Unreal material editor foundation - how to connect a basic material
使用Windbg静态分析dump文件(实战经验总结)
pytest框架实现前后置
Flink calculates topn hot list in real time
Ctrip starts mixed office. How can small and medium-sized enterprises achieve mixed office?
【避坑指南】Unity3D项目接入腾讯Bugly工具时遇到的坑