From ab0fc847810f91117fdc8a3d932d339be1c2a384 Mon Sep 17 00:00:00 2001 From: Alexander Reshetnikov Date: Sat, 31 Mar 2012 15:10:13 +0000 Subject: [PATCH] Fixed compilation error under Ubuntu 11.10; added #if-#else-#endif code for some deprecated functions --- modules/highgui/src/cap_ffmpeg_impl_v2.hpp | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/highgui/src/cap_ffmpeg_impl_v2.hpp b/modules/highgui/src/cap_ffmpeg_impl_v2.hpp index 73abb89d7a..8b618ce451 100755 --- a/modules/highgui/src/cap_ffmpeg_impl_v2.hpp +++ b/modules/highgui/src/cap_ffmpeg_impl_v2.hpp @@ -351,7 +351,11 @@ bool CvCapture_FFMPEG::reopen() // reopen video avformat_open_input(&ic, filename, NULL, NULL); - av_find_stream_info(ic); + #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0) + avformat_find_stream_info(ic); + #else + av_find_stream_info(ic); + #endif #if LIBAVFORMAT_BUILD > 4628 AVCodecContext *enc = ic->streams[video_stream]->codec; #else @@ -407,7 +411,12 @@ bool CvCapture_FFMPEG::open( const char* _filename ) CV_WARN("Error opening file"); goto exit_func; } - err = av_find_stream_info(ic); + err = + #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0) + avformat_find_stream_info(ic); + #else + av_find_stream_info(ic); + #endif if (err < 0) { CV_WARN("Could not find codec parameters"); goto exit_func; @@ -960,8 +969,12 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, int frame_rate, frame_rate_base; AVCodec *codec; + #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 10, 0) + st = avformat_new_stream(oc, 0); + #else + st = av_new_stream(oc, 0); + #endif - st = avformat_new_stream(oc, 0); if (!st) { CV_WARN("Could not allocate stream"); return NULL; @@ -1427,7 +1440,13 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, c->bit_rate_tolerance = c->bit_rate; /* open the codec */ - if ( (err=avcodec_open(c, codec)) < 0) { + if ((err= + #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0) + avcodec_open2(c, codec, NULL) + #else + avcodec_open(c, codec) + #endif + ) < 0) { char errtext[256]; sprintf(errtext, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err)); return false; -- GitLab