Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
2b2e3ee9
Commit
2b2e3ee9
authored
Apr 22, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure opencv builds fine with the recent versions of libav (e.g. from Ubuntu 14.10)
parent
a69b435c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
13 deletions
+50
-13
ffmpeg_version.cmake
3rdparty/ffmpeg/ffmpeg_version.cmake
+3
-0
CMakeLists.txt
CMakeLists.txt
+1
-0
OpenCVFindLibsVideo.cmake
cmake/OpenCVFindLibsVideo.cmake
+9
-1
cap.cpp
modules/videoio/src/cap.cpp
+2
-2
cap_ffmpeg_impl.hpp
modules/videoio/src/cap_ffmpeg_impl.hpp
+34
-10
ffmpeg_codecs.hpp
modules/videoio/src/ffmpeg_codecs.hpp
+0
-0
test_ffmpeg.cpp
modules/videoio/test/test_ffmpeg.cpp
+1
-0
No files found.
3rdparty/ffmpeg/ffmpeg_version.cmake
View file @
2b2e3ee9
...
...
@@ -3,9 +3,11 @@ set(HAVE_FFMPEG_CODEC 1)
set
(
HAVE_FFMPEG_FORMAT 1
)
set
(
HAVE_FFMPEG_UTIL 1
)
set
(
HAVE_FFMPEG_SWSCALE 1
)
set
(
HAVE_FFMPEG_RESAMPLE 0
)
set
(
HAVE_GENTOO_FFMPEG 1
)
set
(
ALIASOF_libavcodec_VERSION 55.18.102
)
set
(
ALIASOF_libavformat_VERSION 55.12.100
)
set
(
ALIASOF_libavutil_VERSION 52.38.100
)
set
(
ALIASOF_libswscale_VERSION 2.3.100
)
set
(
ALIASOF_libavresample_VERSION 1.0.1
)
\ No newline at end of file
CMakeLists.txt
View file @
2b2e3ee9
...
...
@@ -931,6 +931,7 @@ if(DEFINED WITH_FFMPEG)
status
(
" format:"
HAVE_FFMPEG_FORMAT THEN
"YES (ver
${
ALIASOF_libavformat_VERSION
}
)"
ELSE NO
)
status
(
" util:"
HAVE_FFMPEG_UTIL THEN
"YES (ver
${
ALIASOF_libavutil_VERSION
}
)"
ELSE NO
)
status
(
" swscale:"
HAVE_FFMPEG_SWSCALE THEN
"YES (ver
${
ALIASOF_libswscale_VERSION
}
)"
ELSE NO
)
status
(
" resample:"
HAVE_FFMPEG_RESAMPLE THEN
"YES (ver
${
ALIASOF_libavresample_VERSION
}
)"
ELSE NO
)
status
(
" gentoo-style:"
HAVE_GENTOO_FFMPEG THEN YES ELSE NO
)
endif
(
DEFINED WITH_FFMPEG
)
...
...
cmake/OpenCVFindLibsVideo.cmake
View file @
2b2e3ee9
...
...
@@ -187,7 +187,7 @@ if(WITH_XIMEA)
endif
(
WITH_XIMEA
)
# --- FFMPEG ---
ocv_clear_vars
(
HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG
)
ocv_clear_vars
(
HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_
FFMPEG_RESAMPLE HAVE_
GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG
)
if
(
WITH_FFMPEG
)
if
(
WIN32 AND NOT ARM
)
include
(
"
${
OpenCV_SOURCE_DIR
}
/3rdparty/ffmpeg/ffmpeg_version.cmake"
)
...
...
@@ -196,6 +196,7 @@ if(WITH_FFMPEG)
CHECK_MODULE
(
libavformat HAVE_FFMPEG_FORMAT
)
CHECK_MODULE
(
libavutil HAVE_FFMPEG_UTIL
)
CHECK_MODULE
(
libswscale HAVE_FFMPEG_SWSCALE
)
CHECK_MODULE
(
libavresample HAVE_FFMPEG_RESAMPLE
)
CHECK_INCLUDE_FILE
(
libavformat/avformat.h HAVE_GENTOO_FFMPEG
)
CHECK_INCLUDE_FILE
(
ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG
)
...
...
@@ -239,6 +240,10 @@ if(WITH_FFMPEG)
set
(
HAVE_FFMPEG_SWSCALE 1
)
set
(
ALIASOF_libswscale_VERSION
"Unknown"
)
set
(
HAVE_FFMPEG 1
)
if
(
EXISTS
"
${
FFMPEG_LIB_DIR
}
/libavresample.a"
)
set
(
HAVE_FFMPEG_RESAMPLE 1
)
set
(
ALIASOF_libavresample_VERSION
"Unknown"
)
endif
()
endif
()
endif
()
endif
()
...
...
@@ -248,6 +253,9 @@ if(WITH_FFMPEG)
set
(
VIDEOIO_LIBRARIES
${
VIDEOIO_LIBRARIES
}
"
${
FFMPEG_LIB_DIR
}
/libavcodec.a"
"
${
FFMPEG_LIB_DIR
}
/libavformat.a"
"
${
FFMPEG_LIB_DIR
}
/libavutil.a"
"
${
FFMPEG_LIB_DIR
}
/libswscale.a"
)
if
(
HAVE_FFMPEG_RESAMPLE
)
set
(
VIDEOIO_LIBRARIES
${
VIDEOIO_LIBRARIES
}
"
${
FFMPEG_LIB_DIR
}
/libavresample.a"
)
endif
()
ocv_include_directories
(
${
FFMPEG_INCLUDE_DIR
}
)
endif
()
endif
(
APPLE
)
...
...
modules/videoio/src/cap.cpp
View file @
2b2e3ee9
...
...
@@ -552,11 +552,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
}
static
Ptr
<
IVideoCapture
>
IVideoCapture_create
(
const
String
&
filename
)
static
Ptr
<
IVideoCapture
>
IVideoCapture_create
(
const
String
&
)
{
Ptr
<
IVideoCapture
>
capture
;
capture
=
createMotionJpegCapture
(
filename
);
//
capture = createMotionJpegCapture(filename);
if
(
capture
&&
capture
->
isOpened
())
{
return
capture
;
...
...
modules/videoio/src/cap_ffmpeg_impl.hpp
View file @
2b2e3ee9
...
...
@@ -786,7 +786,9 @@ double CvCapture_FFMPEG::getProperty( int property_id ) const
case
CV_FFMPEG_CAP_PROP_FRAME_HEIGHT
:
return
(
double
)
frame
.
height
;
case
CV_FFMPEG_CAP_PROP_FPS
:
#if LIBAVCODEC_BUILD > 4753
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0)
return
av_q2d
(
video_st
->
avg_frame_rate
);
#elif LIBAVCODEC_BUILD > 4753
return
av_q2d
(
video_st
->
r_frame_rate
);
#else
return
(
double
)
video_st
->
codec
.
frame_rate
...
...
@@ -834,7 +836,11 @@ int CvCapture_FFMPEG::get_bitrate() const
double
CvCapture_FFMPEG
::
get_fps
()
const
{
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0)
double
fps
=
r2d
(
ic
->
streams
[
video_stream
]
->
avg_frame_rate
);
#else
double
fps
=
r2d
(
ic
->
streams
[
video_stream
]
->
r_frame_rate
);
#endif
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
if
(
fps
<
eps_zero
)
...
...
@@ -1223,7 +1229,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
and qmin since they will be set to reasonable defaults by the libx264
preset system. Also, use a crf encode with the default quality rating,
this seems easier than finding an appropriate default bitrate. */
if
(
c
->
codec_id
==
CODEC_ID_H264
)
{
if
(
c
->
codec_id
==
AV_
CODEC_ID_H264
)
{
c
->
gop_size
=
-
1
;
c
->
qmin
=
-
1
;
c
->
bit_rate
=
0
;
...
...
@@ -1251,8 +1257,7 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
#else
AVCodecContext
*
c
=
&
(
video_st
->
codec
);
#endif
int
out_size
;
int
ret
=
0
;
int
ret
=
OPENCV_NO_FRAMES_WRITTEN_CODE
;
if
(
oc
->
oformat
->
flags
&
AVFMT_RAWPICTURE
)
{
/* raw video case. The API will change slightly in the near
...
...
@@ -1272,12 +1277,32 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
ret
=
av_write_frame
(
oc
,
&
pkt
);
}
else
{
/* encode the image */
out_size
=
avcodec_encode_video
(
c
,
outbuf
,
outbuf_size
,
picture
);
/* if zero size, it means the image was buffered */
if
(
out_size
>
0
)
{
AVPacket
pkt
;
av_init_packet
(
&
pkt
);
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0)
int
got_output
=
0
;
pkt
.
data
=
NULL
;
pkt
.
size
=
0
;
ret
=
avcodec_encode_video2
(
c
,
&
pkt
,
picture
,
&
got_output
);
if
(
ret
<
0
)
got_output
=
0
;
else
if
(
got_output
)
{
//if (c->coded_frame->pts != (int64_t)AV_NOPTS_VALUE)
// pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_st->time_base);
//if (c->coded_frame->dts != (int64_t)AV_NOPTS_VALUE)
// pkt.dts = av_rescale_q(c->coded_frame->dts, c->time_base, video_st->time_base);
//if (pkt.duration)
// pkt.duration = av_rescale_q(pkt.duration, c->time_base, video_st->time_base);
pkt
.
stream_index
=
video_st
->
index
;
ret
=
av_write_frame
(
oc
,
&
pkt
);
av_free_packet
(
&
pkt
);
}
else
ret
=
OPENCV_NO_FRAMES_WRITTEN_CODE
;
#else
int
out_size
=
avcodec_encode_video
(
c
,
outbuf
,
outbuf_size
,
picture
);
/* if zero size, it means the image was buffered */
if
(
out_size
>
0
)
{
#if LIBAVFORMAT_BUILD > 4752
if
(
c
->
coded_frame
->
pts
!=
(
int64_t
)
AV_NOPTS_VALUE
)
pkt
.
pts
=
av_rescale_q
(
c
->
coded_frame
->
pts
,
c
->
time_base
,
video_st
->
time_base
);
...
...
@@ -1292,9 +1317,8 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
/* write the compressed frame in the media file */
ret
=
av_write_frame
(
oc
,
&
pkt
);
}
else
{
ret
=
OPENCV_NO_FRAMES_WRITTEN_CODE
;
}
#endif
}
return
ret
;
}
...
...
modules/videoio/src/ffmpeg_codecs.hpp
View file @
2b2e3ee9
This diff is collapsed.
Click to expand it.
modules/videoio/test/test_ffmpeg.cpp
View file @
2b2e3ee9
...
...
@@ -132,6 +132,7 @@ public:
writer
<<
img
;
}
writer
.
release
();
if
(
!
created
)
created
=
true
;
else
remove
(
filename
.
c_str
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment