Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
024c8364
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
024c8364
编写于
4月 25, 2023
作者:
C
cudawarped
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cv::VideoCapture: change CAP_PROP_FOURCC to prefer codec_id over codec_tag
上级
44881592
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
35 deletion
+49
-35
modules/videoio/src/cap_ffmpeg_impl.hpp
modules/videoio/src/cap_ffmpeg_impl.hpp
+31
-32
modules/videoio/test/test_ffmpeg.cpp
modules/videoio/test/test_ffmpeg.cpp
+18
-3
未找到文件。
modules/videoio/src/cap_ffmpeg_impl.hpp
浏览文件 @
024c8364
...
...
@@ -1707,14 +1707,36 @@ bool CvCapture_FFMPEG::retrieveHWFrame(cv::OutputArray output)
#endif
}
static
inline
double
getCodecTag
(
const
AVCodecID
codec_id
)
{
const
struct
AVCodecTag
*
fallback_tags
[]
=
{
// APIchanges:
// 2012-01-31 - dd6d3b0 - lavf 54.01.0
// Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags().
avformat_get_riff_video_tags
(),
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 25, 100) && defined LIBAVFORMAT_VERSION_MICRO && LIBAVFORMAT_VERSION_MICRO >= 100
// APIchanges: ffmpeg only
// 2014-01-19 - 1a193c4 - lavf 55.25.100 - avformat.h
// Add avformat_get_mov_video_tags() and avformat_get_mov_audio_tags().
avformat_get_mov_video_tags
(),
#endif
codec_bmp_tags
,
// fallback for avformat < 54.1
NULL
};
return
av_codec_get_tag
(
fallback_tags
,
codec_id
);
}
static
inline
double
getCodecIdFourcc
(
const
AVCodecID
codec_id
)
{
if
(
codec_id
==
AV_CODEC_ID_NONE
)
return
-
1
;
const
char
*
codec_fourcc
=
_opencv_avcodec_get_name
(
codec_id
);
if
(
!
codec_fourcc
||
strcmp
(
codec_fourcc
,
"unknown_codec"
)
==
0
||
strlen
(
codec_fourcc
)
!=
4
)
return
getCodecTag
(
codec_id
);
return
(
double
)
CV_FOURCC
(
codec_fourcc
[
0
],
codec_fourcc
[
1
],
codec_fourcc
[
2
],
codec_fourcc
[
3
]);
}
double
CvCapture_FFMPEG
::
getProperty
(
int
property_id
)
const
{
if
(
!
video_st
||
!
context
)
return
0
;
double
codec_tag
=
0
;
CV_CODEC_ID
codec_id
=
AV_CODEC_ID_NONE
;
const
char
*
codec_fourcc
=
NULL
;
switch
(
property_id
)
{
case
CAP_PROP_POS_MSEC
:
...
...
@@ -1738,34 +1760,11 @@ double CvCapture_FFMPEG::getProperty( int property_id ) const
case
CAP_PROP_FPS
:
return
get_fps
();
case
CAP_PROP_FOURCC
:
{
codec_id
=
video_st
->
CV_FFMPEG_CODEC_FIELD
->
codec_id
;
codec_tag
=
(
double
)
video_st
->
CV_FFMPEG_CODEC_FIELD
->
codec_tag
;
if
(
codec_tag
||
codec_id
==
AV_CODEC_ID_NONE
)
{
return
codec_tag
;
}
codec_fourcc
=
_opencv_avcodec_get_name
(
codec_id
);
if
(
!
codec_fourcc
||
strcmp
(
codec_fourcc
,
"unknown_codec"
)
==
0
||
strlen
(
codec_fourcc
)
!=
4
)
{
const
struct
AVCodecTag
*
fallback_tags
[]
=
{
// APIchanges:
// 2012-01-31 - dd6d3b0 - lavf 54.01.0
// Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags().
avformat_get_riff_video_tags
(),
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 25, 100) && defined LIBAVFORMAT_VERSION_MICRO && LIBAVFORMAT_VERSION_MICRO >= 100
// APIchanges: ffmpeg only
// 2014-01-19 - 1a193c4 - lavf 55.25.100 - avformat.h
// Add avformat_get_mov_video_tags() and avformat_get_mov_audio_tags().
avformat_get_mov_video_tags
(),
#endif
codec_bmp_tags
,
// fallback for avformat < 54.1
NULL
};
return
av_codec_get_tag
(
fallback_tags
,
codec_id
);
}
return
(
double
)
CV_FOURCC
(
codec_fourcc
[
0
],
codec_fourcc
[
1
],
codec_fourcc
[
2
],
codec_fourcc
[
3
]);
const
double
fourcc
=
getCodecIdFourcc
(
video_st
->
CV_FFMPEG_CODEC_FIELD
->
codec_id
);
if
(
fourcc
!=
-
1
)
return
fourcc
;
const
double
codec_tag
=
(
double
)
video_st
->
CV_FFMPEG_CODEC_FIELD
->
codec_tag
;
if
(
codec_tag
)
return
codec_tag
;
else
return
-
1
;
}
case
CAP_PROP_SAR_NUM
:
return
_opencv_ffmpeg_get_sample_aspect_ratio
(
ic
->
streams
[
video_stream
]).
num
;
...
...
modules/videoio/test/test_ffmpeg.cpp
浏览文件 @
024c8364
...
...
@@ -226,7 +226,11 @@ const videoio_container_params_t videoio_container_params[] =
videoio_container_params_t
(
CAP_FFMPEG
,
"video/big_buck_bunny"
,
"h264"
,
"h264"
,
"h264"
,
"I420"
),
videoio_container_params_t
(
CAP_FFMPEG
,
"video/big_buck_bunny"
,
"h265"
,
"h265"
,
"hevc"
,
"I420"
),
videoio_container_params_t
(
CAP_FFMPEG
,
"video/big_buck_bunny"
,
"mjpg.avi"
,
"mjpg"
,
"MJPG"
,
"I420"
),
#ifdef _WIN32 // handle old FFmpeg backend - remove when windows shared library is updated
videoio_container_params_t
(
CAP_FFMPEG
,
"video/sample_322x242_15frames.yuv420p.libx264"
,
"mp4"
,
"h264"
,
"avc1"
,
"I420"
)
#else
videoio_container_params_t
(
CAP_FFMPEG
,
"video/sample_322x242_15frames.yuv420p.libx264"
,
"mp4"
,
"h264"
,
"h264"
,
"I420"
)
#endif
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264.mkv", "mkv.h264", "h264", "I420"),
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h265.mkv", "mkv.h265", "hevc", "I420"),
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264.mp4", "mp4.avc1", "avc1", "I420"),
...
...
@@ -448,10 +452,21 @@ TEST_P(ffmpeg_get_fourcc, check_short_codecs)
const
ffmpeg_get_fourcc_param_t
ffmpeg_get_fourcc_param
[]
=
{
ffmpeg_get_fourcc_param_t
(
"../cv/tracking/faceocc2/data/faceocc2.webm"
,
"VP80"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4"
,
"vp09"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libaom-av1.mp4"
,
"av01"
),
ffmpeg_get_fourcc_param_t
(
"video/big_buck_bunny.h265"
,
"hevc"
),
ffmpeg_get_fourcc_param_t
(
"video/big_buck_bunny.h264"
,
"h264"
)
ffmpeg_get_fourcc_param_t
(
"video/big_buck_bunny.h264"
,
"h264"
),
#ifdef _WIN32 // handle old FFmpeg backend - remove when windows shared library is updated
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4"
,
"vp09"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libaom-av1.mp4"
,
"av01"
)
#else
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4"
,
"VP90"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libaom-av1.mp4"
,
"AV01"
),
ffmpeg_get_fourcc_param_t
(
"video/big_buck_bunny.mp4"
,
"FMP4"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.mpeg2video.mp4"
,
"mpg2"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.mjpeg.mp4"
,
"MJPG"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libxvid.mp4"
,
"FMP4"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libx265.mp4"
,
"hevc"
),
ffmpeg_get_fourcc_param_t
(
"video/sample_322x242_15frames.yuv420p.libx264.mp4"
,
"h264"
)
#endif
};
INSTANTIATE_TEST_CASE_P
(
videoio
,
ffmpeg_get_fourcc
,
testing
::
ValuesIn
(
ffmpeg_get_fourcc_param
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录