Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f83aa74b
O
Opencv
项目概览
Greenplum
/
Opencv
10 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f83aa74b
编写于
2月 18, 2012
作者:
A
Alexander Reshetnikov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated ffmpeg implementation (setProperty & getProperty methods)
上级
a6e8e5dd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
11 deletion
+38
-11
modules/highgui/src/cap_ffmpeg_impl.hpp
modules/highgui/src/cap_ffmpeg_impl.hpp
+38
-11
未找到文件。
modules/highgui/src/cap_ffmpeg_impl.hpp
浏览文件 @
f83aa74b
...
...
@@ -384,6 +384,7 @@ struct CvCapture_FFMPEG
void
close
();
double
getProperty
(
int
);
bool
seekKeyAndRunOverFrames
(
int
framenumber
);
bool
setProperty
(
int
,
double
);
bool
grabFrame
();
bool
retrieveFrame
(
int
,
unsigned
char
**
data
,
int
*
step
,
int
*
width
,
int
*
height
,
int
*
cn
);
...
...
@@ -510,6 +511,9 @@ bool CvCapture_FFMPEG::reopen()
#ifndef AVSEEK_FLAG_ANY
#define AVSEEK_FLAG_ANY 1
#endif
#ifndef SHORTER_DISTANCE_FOR_SEEK_TO_MAKE_IT_FASTER
#define SHORTER_DISTANCE_FOR_SEEK_TO_MAKE_IT_FASTER 25
#endif
bool
CvCapture_FFMPEG
::
open
(
const
char
*
_filename
)
{
...
...
@@ -724,7 +728,7 @@ double CvCapture_FFMPEG::getProperty( int property_id )
{
case
CV_FFMPEG_CAP_PROP_POS_MSEC
:
if
(
video_st
->
parser
&&
video_st
->
parser
->
dts
!=
AV_NOPTS_VALUE_
)
return
(((
double
)
video_st
->
parser
->
dts
-
1
)
*
1000.0
f
)
*
av_q2d
(
video_st
->
time_base
);
return
(((
double
)
video_st
->
parser
->
dts
-
1
)
*
1000.0
)
*
av_q2d
(
video_st
->
time_base
);
if
(
video_st
->
cur_dts
!=
AV_NOPTS_VALUE_
)
return
((
video_st
->
cur_dts
-
video_st
->
first_dts
)
*
1000.0
*
av_q2d
(
video_st
->
time_base
));
break
;
...
...
@@ -742,7 +746,7 @@ double CvCapture_FFMPEG::getProperty( int property_id )
break
;
case
CV_FFMPEG_CAP_PROP_FRAME_COUNT
:
if
(
video_st
->
duration
!=
AV_NOPTS_VALUE_
)
return
(
double
)
video_st
->
duration
*
frameScale
;
return
(
double
)
ceil
(
ic
->
duration
*
av_q2d
(
video_st
->
r_frame_rate
)
/
AV_TIME_BASE
)
;
break
;
case
CV_FFMPEG_CAP_PROP_FRAME_WIDTH
:
return
(
double
)
frame
.
width
;
...
...
@@ -787,10 +791,36 @@ bool CvCapture_FFMPEG::slowSeek( int framenumber )
return
true
;
}
bool
CvCapture_FFMPEG
::
seekKeyAndRunOverFrames
(
int
framenumber
)
{
int
ret
;
if
(
framenumber
>
video_st
->
cur_dts
-
1
)
{
if
(
framenumber
-
(
video_st
->
cur_dts
-
1
)
>
SHORTER_DISTANCE_FOR_SEEK_TO_MAKE_IT_FASTER
)
{
ret
=
av_seek_frame
(
ic
,
video_stream
,
framenumber
,
1
);
assert
(
ret
>=
0
);
if
(
ret
<
0
)
return
false
;
}
grabFrame
();
while
((
video_st
->
cur_dts
-
1
)
<
framenumber
)
if
(
!
grabFrame
()
)
return
false
;
}
else
if
(
framenumber
<
(
video_st
->
cur_dts
-
1
)
)
{
ret
=
av_seek_frame
(
ic
,
video_stream
,
framenumber
,
1
);
assert
(
ret
>=
0
);
if
(
ret
<
0
)
return
false
;
grabFrame
();
while
((
video_st
->
cur_dts
-
1
)
<
framenumber
)
if
(
!
grabFrame
()
)
return
false
;
}
return
true
;
}
bool
CvCapture_FFMPEG
::
setProperty
(
int
property_id
,
double
value
)
{
if
(
!
video_st
)
return
false
;
int
framenumber
=
0
;
switch
(
property_id
)
{
...
...
@@ -805,21 +835,18 @@ bool CvCapture_FFMPEG::setProperty( int property_id, double value )
switch
(
property_id
)
{
case
CV_FFMPEG_CAP_PROP_POS_FRAMES
:
timestamp
+=
(
int64_t
)(
value
*
timeScale
);
if
(
ic
->
start_time
!=
AV_NOPTS_VALUE_
)
timestamp
+=
ic
->
start_time
;
framenumber
=
(
int
)
value
;
seekKeyAndRunOverFrames
(
framenumber
);
break
;
case
CV_FFMPEG_CAP_PROP_POS_MSEC
:
timestamp
+=
(
int64_t
)(
value
*
(
float
(
time_base
.
den
)
/
float
(
time_base
.
num
))
/
1000
);
if
(
ic
->
start_time
!=
AV_NOPTS_VALUE_
)
timestamp
+=
ic
->
start_time
;
framenumber
=
(
int
)(
value
/
(
1000.0
f
*
av_q2d
(
video_st
->
time_base
)));
seekKeyAndRunOverFrames
(
framenumber
);
break
;
case
CV_FFMPEG_CAP_PROP_POS_AVI_RATIO
:
timestamp
+=
(
int64_t
)(
value
*
ic
->
duration
);
if
(
ic
->
start_time
!=
AV_NOPTS_VALUE_
&&
ic
->
duration
!=
AV_NOPTS_VALUE_
)
timestamp
+=
ic
->
start_time
;
framenumber
=
(
int
)(
value
*
ic
->
duration
);
seekKeyAndRunOverFrames
(
framenumber
);
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录