summaryrefslogtreecommitdiff
path: root/recipes-support/opencv
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2015-03-09 13:46:10 +0100
committerMax Krummenacher <max.krummenacher@toradex.com>2015-05-12 10:04:34 +0200
commit48d95d0878b84c42a194800d904ff93908b9b785 (patch)
tree530704bf270761e3913d0faaef2cbb195442fc2e /recipes-support/opencv
parent12cc5a4b1bd7cb6da2d91d3dd302f0451cfec6d9 (diff)
opencv: add patches for libav 10.x API
Diffstat (limited to 'recipes-support/opencv')
-rw-r--r--recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch724
-rw-r--r--recipes-support/opencv/opencv/0002-cap_ffmpeg-drop-the-local-copy-of-the-RIFF-FourCC-li.patch325
-rw-r--r--recipes-support/opencv/opencv/0003-cap_ffmpeg-wrap-a-forgotten-instance-of-CODEC_ID_H26.patch27
-rw-r--r--recipes-support/opencv/opencv/0004-cap_ffmpeg-do-not-use-AVStream.r_frame_rate.patch47
-rw-r--r--recipes-support/opencv/opencv/0005-cap_ffmpeg-use-avcodec_encode_video2-where-available.patch80
-rw-r--r--recipes-support/opencv/opencv_2.4.bbappend14
6 files changed, 1217 insertions, 0 deletions
diff --git a/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch b/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch
new file mode 100644
index 0000000..622d39c
--- /dev/null
+++ b/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch
@@ -0,0 +1,724 @@
+From db36d3abccf02242459419919619bad2fdb5ea24 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton@khirnov.net>
+Date: Thu, 6 Feb 2014 09:28:07 +0100
+Subject: [PATCH 1/5] cap_ffmpeg: drop support for very old libav* versions
+
+All relevant distros now ship the equivalent of Libav 0.8 or newer, so
+drop support for everything older as it is a maintenance burden.
+
+(cherry picked from commit 39f27edf24c90cbb811c1795524da1f1e159792e)
+
+Conflicts:
+ modules/highgui/src/cap_ffmpeg_impl.hpp
+---
+ modules/highgui/src/cap_ffmpeg_impl.hpp | 294 +++-----------------------------
+ 1 file changed, 27 insertions(+), 267 deletions(-)
+
+diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp
+index 2b18559..c0a4882 100644
+--- a/modules/highgui/src/cap_ffmpeg_impl.hpp
++++ b/modules/highgui/src/cap_ffmpeg_impl.hpp
+@@ -61,6 +61,8 @@ extern "C" {
+
+ #include <libavutil/mathematics.h>
+
++#include <libavutil/opt.h>
++
+ #ifdef WIN32
+ #define HAVE_FFMPEG_SWSCALE 1
+ #include <libavcodec/avcodec.h>
+@@ -144,10 +146,6 @@ extern "C" {
+ #define AV_NOPTS_VALUE_ ((int64_t)AV_NOPTS_VALUE)
+ #endif
+
+-#ifndef AVERROR_EOF
+-#define AVERROR_EOF (-MKTAG( 'E','O','F',' '))
+-#endif
+-
+ #if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54,25,0)
+ # define CV_CODEC_ID AVCodecID
+ # define CV_CODEC(name) AV_##name
+@@ -158,9 +156,7 @@ extern "C" {
+
+ static int get_number_of_cpus(void)
+ {
+-#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(52, 111, 0)
+- return 1;
+-#elif defined WIN32 || defined _WIN32
++#if defined WIN32 || defined _WIN32
+ SYSTEM_INFO sysinfo;
+ GetSystemInfo( &sysinfo );
+
+@@ -296,25 +292,13 @@ void CvCapture_FFMPEG::close()
+
+ if( video_st )
+ {
+-#if LIBAVFORMAT_BUILD > 4628
+ avcodec_close( video_st->codec );
+-
+-#else
+- avcodec_close( &(video_st->codec) );
+-
+-#endif
+ video_st = NULL;
+ }
+
+ if( ic )
+ {
+-#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 24, 2)
+- av_close_input_file(ic);
+-#else
+ avformat_close_input(&ic);
+-#endif
+-
+- ic = NULL;
+ }
+
+ if( rgb_picture.data[0] )
+@@ -501,9 +485,7 @@ public:
+ _mutex.lock();
+ if (!_initialized)
+ {
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
+ avformat_network_init();
+- #endif
+
+ /* register all codecs, demux and protocols */
+ av_register_all();
+@@ -534,11 +516,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
+
+ close();
+
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
+ int err = avformat_open_input(&ic, _filename, NULL, NULL);
+-#else
+- int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);
+-#endif
+
+ if (err < 0)
+ {
+@@ -546,11 +524,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
+ goto exit_func;
+ }
+ err =
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
+ avformat_find_stream_info(ic, NULL);
+-#else
+- av_find_stream_info(ic);
+-#endif
+ if (err < 0)
+ {
+ CV_WARN("Could not find codec parameters");
+@@ -558,11 +532,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
+ }
+ for(i = 0; i < ic->nb_streams; i++)
+ {
+-#if LIBAVFORMAT_BUILD > 4628
+ AVCodecContext *enc = ic->streams[i]->codec;
+-#else
+- AVCodecContext *enc = &ic->streams[i]->codec;
+-#endif
+
+ //#ifdef FF_API_THREAD_INIT
+ // avcodec_thread_init(enc, get_number_of_cpus());
+@@ -570,10 +540,6 @@ bool CvCapture_FFMPEG::open( const char* _filename )
+ enc->thread_count = get_number_of_cpus();
+ //#endif
+
+-#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 2, 0)
+-#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
+-#endif
+-
+ if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0)
+ {
+ // backup encoder' width/height
+@@ -581,13 +547,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
+ int enc_height = enc->height;
+
+ AVCodec *codec = avcodec_find_decoder(enc->codec_id);
+- if (!codec ||
+-#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
+- avcodec_open2(enc, codec, NULL)
+-#else
+- avcodec_open(enc, codec)
+-#endif
+- < 0)
++ if (!codec || avcodec_open2(enc, codec, NULL) < 0)
+ goto exit_func;
+
+ // checking width/height (since decoder can sometimes alter it, eg. vp6f)
+@@ -660,17 +620,7 @@ bool CvCapture_FFMPEG::grabFrame()
+ }
+
+ // Decode video frame
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+ avcodec_decode_video2(video_st->codec, picture, &got_picture, &packet);
+- #elif LIBAVFORMAT_BUILD > 4628
+- avcodec_decode_video(video_st->codec,
+- picture, &got_picture,
+- packet.data, packet.size);
+- #else
+- avcodec_decode_video(&video_st->codec,
+- picture, &got_picture,
+- packet.data, packet.size);
+- #endif
+
+ // Did we get a video frame?
+ if(got_picture)
+@@ -769,18 +719,9 @@ double CvCapture_FFMPEG::getProperty( int property_id )
+ case CV_FFMPEG_CAP_PROP_FRAME_HEIGHT:
+ return (double)frame.height;
+ case CV_FFMPEG_CAP_PROP_FPS:
+-#if LIBAVCODEC_BUILD > 4753
+ return av_q2d(video_st->r_frame_rate);
+-#else
+- return (double)video_st->codec.frame_rate
+- / (double)video_st->codec.frame_rate_base;
+-#endif
+ case CV_FFMPEG_CAP_PROP_FOURCC:
+-#if LIBAVFORMAT_BUILD > 4628
+ return (double)video_st->codec->codec_tag;
+-#else
+- return (double)video_st->codec.codec_tag;
+-#endif
+ default:
+ break;
+ }
+@@ -819,12 +760,10 @@ double CvCapture_FFMPEG::get_fps()
+ {
+ double fps = r2d(ic->streams[video_stream]->r_frame_rate);
+
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
+ if (fps < eps_zero)
+ {
+ fps = r2d(ic->streams[video_stream]->avg_frame_rate);
+ }
+-#endif
+
+ if (fps < eps_zero)
+ {
+@@ -984,7 +923,6 @@ struct CvVideoWriter_FFMPEG
+
+ static const char * icvFFMPEGErrStr(int err)
+ {
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+ switch(err) {
+ case AVERROR_BSF_NOT_FOUND:
+ return "Bitstream filter not found";
+@@ -1015,22 +953,6 @@ static const char * icvFFMPEGErrStr(int err)
+ default:
+ break;
+ }
+-#else
+- switch(err) {
+- case AVERROR_NUMEXPECTED:
+- return "Incorrect filename syntax";
+- case AVERROR_INVALIDDATA:
+- return "Invalid data in header";
+- case AVERROR_NOFMT:
+- return "Unknown format";
+- case AVERROR_IO:
+- return "I/O error occurred";
+- case AVERROR_NOMEM:
+- return "Memory allocation error";
+- default:
+- break;
+- }
+-#endif
+
+ return "Unspecified error";
+ }
+@@ -1098,28 +1020,16 @@ 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
+
+ if (!st) {
+ CV_WARN("Could not allocate stream");
+ return NULL;
+ }
+
+-#if LIBAVFORMAT_BUILD > 4628
+ c = st->codec;
+-#else
+- c = &(st->codec);
+-#endif
+
+-#if LIBAVFORMAT_BUILD > 4621
+ c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO);
+-#else
+- c->codec_id = oc->oformat->video_codec;
+-#endif
+
+ if(codec_id != CV_CODEC(CODEC_ID_NONE)){
+ c->codec_id = codec_id;
+@@ -1154,7 +1064,6 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
+ frame_rate_base*=10;
+ frame_rate=(int)(fps*frame_rate_base + 0.5);
+ }
+-#if LIBAVFORMAT_BUILD > 4752
+ c->time_base.den = frame_rate;
+ c->time_base.num = frame_rate_base;
+ /* adjust time base for supported framerates */
+@@ -1174,10 +1083,6 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
+ c->time_base.den= best->num;
+ c->time_base.num= best->den;
+ }
+-#else
+- c->frame_rate = frame_rate;
+- c->frame_rate_base = frame_rate_base;
+-#endif
+
+ c->gop_size = 12; /* emit one intra frame every twelve frames at most */
+ c->pix_fmt = (PixelFormat) pixel_format;
+@@ -1192,13 +1097,25 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
+ /* avoid FFMPEG warning 'clipping 1 dct coefficients...' */
+ c->mb_decision=2;
+ }
+-#if LIBAVCODEC_VERSION_INT>0x000409
++
++#if LIBAVUTIL_BUILD > CALC_FFMPEG_VERSION(51,11,0)
++ /* Some settings for libx264 encoding, restore dummy values for gop_size
++ 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) {
++ c->gop_size = -1;
++ c->qmin = -1;
++ c->bit_rate = 0;
++ av_opt_set(c->priv_data,"crf","23", 0);
++ }
++#endif
++
+ // some formats want stream headers to be seperate
+ if(oc->oformat->flags & AVFMT_GLOBALHEADER)
+ {
+ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ }
+-#endif
+
+ return st;
+ }
+@@ -1207,11 +1124,7 @@ static const int OPENCV_NO_FRAMES_WRITTEN_CODE = 1000;
+
+ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_t * outbuf, uint32_t outbuf_size, AVFrame * picture )
+ {
+-#if LIBAVFORMAT_BUILD > 4628
+ AVCodecContext * c = video_st->codec;
+-#else
+- AVCodecContext * c = &(video_st->codec);
+-#endif
+ int out_size;
+ int ret = 0;
+
+@@ -1239,12 +1152,8 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
+ AVPacket pkt;
+ av_init_packet(&pkt);
+
+-#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);
+-#else
+- pkt.pts = c->coded_frame->pts;
+-#endif
+ if(c->coded_frame->key_frame)
+ pkt.flags |= PKT_FLAG_KEY;
+ pkt.stream_index= video_st->index;
+@@ -1271,30 +1180,8 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int
+ height = frame_height;
+
+ // typecast from opaque data type to implemented struct
+-#if LIBAVFORMAT_BUILD > 4628
+ AVCodecContext *c = video_st->codec;
+-#else
+- AVCodecContext *c = &(video_st->codec);
+-#endif
+
+-#if LIBAVFORMAT_BUILD < 5231
+- // It is not needed in the latest versions of the ffmpeg
+- if( c->codec_id == CV_CODEC(CODEC_ID_RAWVIDEO) && origin != 1 )
+- {
+- if( !temp_image.data )
+- {
+- temp_image.step = (width*cn + 3) & -4;
+- temp_image.width = width;
+- temp_image.height = height;
+- temp_image.cn = cn;
+- temp_image.data = (unsigned char*)malloc(temp_image.step*temp_image.height);
+- }
+- for( int y = 0; y < height; y++ )
+- memcpy(temp_image.data + y*temp_image.step, data + (height-1-y)*step, width*cn);
+- data = temp_image.data;
+- step = temp_image.step;
+- }
+-#else
+ if( width*cn != step )
+ {
+ if( !temp_image.data )
+@@ -1314,7 +1201,6 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int
+ data = temp_image.data;
+ step = temp_image.step;
+ }
+-#endif
+
+ // check parameters
+ if (input_pix_fmt == PIX_FMT_BGR24) {
+@@ -1401,11 +1287,7 @@ void CvVideoWriter_FFMPEG::close()
+ }
+
+ // free pictures
+-#if LIBAVFORMAT_BUILD > 4628
+ if( video_st->codec->pix_fmt != input_pix_fmt)
+-#else
+- if( video_st->codec.pix_fmt != input_pix_fmt)
+-#endif
+ {
+ if(picture->data[0])
+ free(picture->data[0]);
+@@ -1417,11 +1299,7 @@ void CvVideoWriter_FFMPEG::close()
+ av_free(input_picture);
+
+ /* close codec */
+-#if LIBAVFORMAT_BUILD > 4628
+ avcodec_close(video_st->codec);
+-#else
+- avcodec_close(&(video_st->codec));
+-#endif
+
+ av_free(outbuf);
+
+@@ -1429,15 +1307,7 @@ void CvVideoWriter_FFMPEG::close()
+ {
+ /* close the output file */
+
+-#if LIBAVCODEC_VERSION_INT < ((52<<16)+(123<<8)+0)
+-#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(49<<8)+0)
+- url_fclose(oc->pb);
+-#else
+- url_fclose(&oc->pb);
+-#endif
+-#else
+ avio_close(oc->pb);
+-#endif
+
+ }
+
+@@ -1479,11 +1349,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+
+ /* auto detect the output format from the name and fourcc code. */
+
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+ fmt = av_guess_format(NULL, filename, NULL);
+-#else
+- fmt = guess_format(NULL, filename, NULL);
+-#endif
+
+ if (!fmt)
+ return false;
+@@ -1497,21 +1363,12 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+ }
+
+ /* Lookup codec_id for given fourcc */
+-#if LIBAVCODEC_VERSION_INT<((51<<16)+(49<<8)+0)
+- if( (codec_id = codec_get_bmp_id( fourcc )) == CV_CODEC(CODEC_ID_NONE) )
+- return false;
+-#else
+ const struct AVCodecTag * tags[] = { codec_bmp_tags, NULL};
+ if( (codec_id = av_codec_get_id(tags, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
+ return false;
+-#endif
+
+ // alloc memory for context
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+ oc = avformat_alloc_context();
+-#else
+- oc = av_alloc_format_context();
+-#endif
+ assert (oc);
+
+ /* set file name */
+@@ -1523,12 +1380,10 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+
+ // set a few optimal pixel formats for lossless codecs of interest..
+ switch (codec_id) {
+-#if LIBAVCODEC_VERSION_INT>((50<<16)+(1<<8)+0)
+ case CV_CODEC(CODEC_ID_JPEGLS):
+ // BGR24 or GRAY8 depending on is_color...
+ codec_pix_fmt = input_pix_fmt;
+ break;
+-#endif
+ case CV_CODEC(CODEC_ID_HUFFYUV):
+ codec_pix_fmt = PIX_FMT_YUV422P;
+ break;
+@@ -1555,14 +1410,6 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+ width, height, (int)(bitrate + 0.5),
+ fps, codec_pix_fmt);
+
+- /* set the output parameters (must be done even if no
+- parameters). */
+-#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 2, 0)
+- if (av_set_parameters(oc, NULL) < 0) {
+- return false;
+- }
+-#endif
+-
+ #if 0
+ #if FF_API_DUMP_FORMAT
+ dump_format(oc, 0, filename, 1);
+@@ -1580,23 +1427,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+ AVCodec *codec;
+ AVCodecContext *c;
+
+-#if LIBAVFORMAT_BUILD > 4628
+ c = (video_st->codec);
+-#else
+- c = &(video_st->codec);
+-#endif
+
+ c->codec_tag = fourcc;
+ /* find the video encoder */
+ codec = avcodec_find_encoder(c->codec_id);
+ if (!codec) {
+ fprintf(stderr, "Could not find encoder for codec id %d: %s", c->codec_id, icvFFMPEGErrStr(
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+- AVERROR_ENCODER_NOT_FOUND
+- #else
+- -1
+- #endif
+- ));
++ AVERROR_ENCODER_NOT_FOUND));
+ return false;
+ }
+
+@@ -1607,13 +1445,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+ c->bit_rate = (int)lbit_rate;
+
+ /* open the codec */
+- if ((err=
+-#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
+- avcodec_open2(c, codec, NULL)
+-#else
+- avcodec_open(c, codec)
+-#endif
+- ) < 0) {
++ if ((err = avcodec_open2(c, codec, NULL)) < 0) {
+ fprintf(stderr, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err));
+ return false;
+ }
+@@ -1649,22 +1481,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+
+ /* open the output file, if needed */
+ if (!(fmt->flags & AVFMT_NOFILE)) {
+-#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 2, 0)
+- if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0)
+-#else
+ if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0)
+-#endif
+ {
+ return false;
+ }
+ }
+
+-#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
+ /* write the stream header, if any */
+ err=avformat_write_header(oc, NULL);
+-#else
+- err=av_write_header( oc );
+-#endif
+
+ if(err < 0)
+ {
+@@ -1799,15 +1623,7 @@ void OutputMediaStream_FFMPEG::close()
+ {
+ // close the output file
+
+- #if LIBAVCODEC_VERSION_INT < ((52<<16)+(123<<8)+0)
+- #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(49<<8)+0)
+- url_fclose(oc_->pb);
+- #else
+- url_fclose(&oc_->pb);
+- #endif
+- #else
+- avio_close(oc_->pb);
+- #endif
++ avio_close(oc_->pb);
+ }
+
+ // free the stream
+@@ -1817,19 +1633,11 @@ void OutputMediaStream_FFMPEG::close()
+
+ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC_ID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format)
+ {
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 10, 0)
+ AVStream* st = avformat_new_stream(oc, 0);
+- #else
+- AVStream* st = av_new_stream(oc, 0);
+- #endif
+ if (!st)
+ return 0;
+
+- #if LIBAVFORMAT_BUILD > 4628
+ AVCodecContext* c = st->codec;
+- #else
+- AVCodecContext* c = &(st->codec);
+- #endif
+
+ c->codec_id = codec_id;
+ c->codec_type = AVMEDIA_TYPE_VIDEO;
+@@ -1865,7 +1673,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
+ c->time_base.den = frame_rate;
+ c->time_base.num = frame_rate_base;
+
+- #if LIBAVFORMAT_BUILD > 4752
+ // adjust time base for supported framerates
+ if (codec && codec->supported_framerates)
+ {
+@@ -1890,7 +1697,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
+ c->time_base.den= best->num;
+ c->time_base.num= best->den;
+ }
+- #endif
+
+ c->gop_size = 12; // emit one intra frame every twelve frames at most
+ c->pix_fmt = pixel_format;
+@@ -1909,13 +1715,11 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
+ c->mb_decision = 2;
+ }
+
+- #if LIBAVCODEC_VERSION_INT > 0x000409
+ // some formats want stream headers to be seperate
+ if (oc->oformat->flags & AVFMT_GLOBALHEADER)
+ {
+ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ }
+- #endif
+
+ return st;
+ }
+@@ -1927,22 +1731,14 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height,
+ video_st_ = 0;
+
+ // auto detect the output format from the name and fourcc code
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+ fmt_ = av_guess_format(NULL, fileName, NULL);
+- #else
+- fmt_ = guess_format(NULL, fileName, NULL);
+- #endif
+ if (!fmt_)
+ return false;
+
+ CV_CODEC_ID codec_id = CV_CODEC(CODEC_ID_H264);
+
+ // alloc memory for context
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
+ oc_ = avformat_alloc_context();
+- #else
+- oc_ = av_alloc_format_context();
+- #endif
+ if (!oc_)
+ return false;
+
+@@ -1961,20 +1757,10 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height,
+ if (!video_st_)
+ return false;
+
+- // set the output parameters (must be done even if no parameters)
+- #if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 2, 0)
+- if (av_set_parameters(oc_, NULL) < 0)
+- return false;
+- #endif
+-
+ // now that all the parameters are set, we can open the audio and
+ // video codecs and allocate the necessary encode buffers
+
+- #if LIBAVFORMAT_BUILD > 4628
+ AVCodecContext* c = (video_st_->codec);
+- #else
+- AVCodecContext* c = &(video_st_->codec);
+- #endif
+
+ c->codec_tag = MKTAG('H', '2', '6', '4');
+ c->bit_rate_tolerance = c->bit_rate;
+@@ -1982,22 +1768,14 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height,
+ // open the output file, if needed
+ if (!(fmt_->flags & AVFMT_NOFILE))
+ {
+- #if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 2, 0)
+- int err = url_fopen(&oc_->pb, fileName, URL_WRONLY);
+- #else
+- int err = avio_open(&oc_->pb, fileName, AVIO_FLAG_WRITE);
+- #endif
++ int err = avio_open(&oc_->pb, fileName, AVIO_FLAG_WRITE);
+
+ if (err != 0)
+ return false;
+ }
+
+ // write the stream header, if any
+- #if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 2, 0)
+- av_write_header(oc_);
+- #else
+- avformat_write_header(oc_, NULL);
+- #endif
++ avformat_write_header(oc_, NULL);
+
+ return true;
+ }
+@@ -2102,33 +1880,19 @@ bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma
+ video_stream_id_ = -1;
+ memset(&pkt_, 0, sizeof(AVPacket));
+
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
+- avformat_network_init();
+- #endif
++ avformat_network_init();
+
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
+- err = avformat_open_input(&ctx_, fileName, 0, 0);
+- #else
+- err = av_open_input_file(&ctx_, fileName, 0, 0, 0);
+- #endif
++ err = avformat_open_input(&ctx_, fileName, 0, 0);
+ if (err < 0)
+ return false;
+
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
+- err = avformat_find_stream_info(ctx_, 0);
+- #else
+- err = av_find_stream_info(ctx_);
+- #endif
++ err = avformat_find_stream_info(ctx_, 0);
+ if (err < 0)
+ return false;
+
+ for (unsigned int i = 0; i < ctx_->nb_streams; ++i)
+ {
+- #if LIBAVFORMAT_BUILD > 4628
+ AVCodecContext *enc = ctx_->streams[i]->codec;
+- #else
+- AVCodecContext *enc = &ctx_->streams[i]->codec;
+- #endif
+
+ if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
+ {
+@@ -2197,11 +1961,7 @@ void InputMediaStream_FFMPEG::close()
+ {
+ if (ctx_)
+ {
+- #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 24, 2)
+- avformat_close_input(&ctx_);
+- #else
+- av_close_input_file(ctx_);
+- #endif
++ avformat_close_input(&ctx_);
+ }
+
+ // free last packet if exist
+--
+1.9.3
+
diff --git a/recipes-support/opencv/opencv/0002-cap_ffmpeg-drop-the-local-copy-of-the-RIFF-FourCC-li.patch b/recipes-support/opencv/opencv/0002-cap_ffmpeg-drop-the-local-copy-of-the-RIFF-FourCC-li.patch
new file mode 100644
index 0000000..bc75d96
--- /dev/null
+++ b/recipes-support/opencv/opencv/0002-cap_ffmpeg-drop-the-local-copy-of-the-RIFF-FourCC-li.patch
@@ -0,0 +1,325 @@
+From ef0049ea996b0b2c24cfe590f6e881919d0d733c Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton@khirnov.net>
+Date: Thu, 6 Feb 2014 09:43:55 +0100
+Subject: [PATCH 2/5] cap_ffmpeg: drop the local copy of the RIFF FourCC list
+
+It is now exported by libavformat through a public API, so there is no
+reason to carry an outdated custom copy.
+
+(cherry picked from commit 45c4128cb82d2f325bc21c1499a7844c178f32a2)
+
+Conflicts:
+ modules/highgui/src/ffmpeg_codecs.hpp
+---
+ modules/highgui/src/cap_ffmpeg_impl.hpp | 20 ++-
+ modules/highgui/src/ffmpeg_codecs.hpp | 259 --------------------------------
+ 2 files changed, 18 insertions(+), 261 deletions(-)
+ delete mode 100644 modules/highgui/src/ffmpeg_codecs.hpp
+
+diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp
+index c0a4882..068642a 100644
+--- a/modules/highgui/src/cap_ffmpeg_impl.hpp
++++ b/modules/highgui/src/cap_ffmpeg_impl.hpp
+@@ -57,8 +57,24 @@
+ extern "C" {
+ #endif
+
+-#include "ffmpeg_codecs.hpp"
++#if !defined(WIN32) || defined(__MINGW32__)
+
++#include <stdint.h>
++
++// some versions of FFMPEG assume a C99 compiler, and don't define INT64_C
++#ifndef INT64_C
++#define INT64_C(c) (c##LL)
++#endif
++
++#ifndef UINT64_C
++#define UINT64_C(c) (c##ULL)
++#endif
++
++#include <errno.h>
++
++#endif
++
++#include <libavformat/avformat.h>
+ #include <libavutil/mathematics.h>
+
+ #include <libavutil/opt.h>
+@@ -1363,7 +1379,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+ }
+
+ /* Lookup codec_id for given fourcc */
+- const struct AVCodecTag * tags[] = { codec_bmp_tags, NULL};
++ const struct AVCodecTag * tags[] = { avformat_get_riff_video_tags(), NULL};
+ if( (codec_id = av_codec_get_id(tags, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
+ return false;
+
+diff --git a/modules/highgui/src/ffmpeg_codecs.hpp b/modules/highgui/src/ffmpeg_codecs.hpp
+deleted file mode 100644
+index ca7f55c..0000000
+--- a/modules/highgui/src/ffmpeg_codecs.hpp
++++ /dev/null
+@@ -1,259 +0,0 @@
+-/*M///////////////////////////////////////////////////////////////////////////////////////
+-//
+-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+-//
+-// By downloading, copying, installing or using the software you agree to this license.
+-// If you do not agree to this license, do not download, install,
+-// copy or use the software.
+-//
+-//
+-// License Agreement
+-// For Open Source Computer Vision Library
+-//
+-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+-// Third party copyrights are property of their respective owners.
+-//
+-// Redistribution and use in source and binary forms, with or without modification,
+-// are permitted provided that the following conditions are met:
+-//
+-// * Redistribution's of source code must retain the above copyright notice,
+-// this list of conditions and the following disclaimer.
+-//
+-// * Redistribution's in binary form must reproduce the above copyright notice,
+-// this list of conditions and the following disclaimer in the documentation
+-// and/or other materials provided with the distribution.
+-//
+-// * The name of the copyright holders may not be used to endorse or promote products
+-// derived from this software without specific prior written permission.
+-//
+-// This software is provided by the copyright holders and contributors "as is" and
+-// any express or implied warranties, including, but not limited to, the implied
+-// warranties of merchantability and fitness for a particular purpose are disclaimed.
+-// In no event shall the Intel Corporation or contributors be liable for any direct,
+-// indirect, incidental, special, exemplary, or consequential damages
+-// (including, but not limited to, procurement of substitute goods or services;
+-// loss of use, data, or profits; or business interruption) however caused
+-// and on any theory of liability, whether in contract, strict liability,
+-// or tort (including negligence or otherwise) arising in any way out of
+-// the use of this software, even if advised of the possibility of such damage.
+-//
+-//M*/
+-
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-
+-#if !defined(WIN32) || defined(__MINGW32__)
+-// some versions of FFMPEG assume a C99 compiler, and don't define INT64_C
+-#include <stdint.h>
+-
+-// some versions of FFMPEG assume a C99 compiler, and don't define INT64_C
+-#ifndef INT64_C
+-#define INT64_C(c) (c##LL)
+-#endif
+-
+-#ifndef UINT64_C
+-#define UINT64_C(c) (c##ULL)
+-#endif
+-
+-#include <errno.h>
+-#endif
+-
+-#ifdef WIN32
+- #include <libavformat/avformat.h>
+-#else
+-
+-// if the header path is not specified explicitly, let's deduce it
+-#if !defined HAVE_FFMPEG_AVCODEC_H && !defined HAVE_LIBAVCODEC_AVCODEC_H
+-
+-#if defined(HAVE_GENTOO_FFMPEG)
+- #define HAVE_LIBAVFORMAT_AVFORMAT_H 1
+-#elif defined HAVE_FFMPEG
+- #define HAVE_FFMPEG_AVFORMAT_H 1
+-#endif
+-
+-#if defined(HAVE_FFMPEG_AVFORMAT_H)
+- #include <ffmpeg/avformat.h>
+-#endif
+-
+-#if defined(HAVE_LIBAVFORMAT_AVFORMAT_H)
+- #include <libavformat/avformat.h>
+-#endif
+-
+-#endif
+-
+-#endif
+-
+-#ifdef __cplusplus
+-}
+-#endif
+-
+-#ifndef MKTAG
+-#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
+-#endif
+-
+-// required to look up the correct codec ID depending on the FOURCC code,
+-// this is just a snipped from the file riff.c from ffmpeg/libavformat
+-typedef struct AVCodecTag {
+- int id;
+- unsigned int tag;
+-} AVCodecTag;
+-
+-const AVCodecTag codec_bmp_tags[] = {
+- { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
+- { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
+- { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
+- { CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
+- { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
+- { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },
+-
+- { CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
+- { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
+- { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */
+- { CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
+-
+- /* added based on MPlayer */
+- { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
+- { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
+-
+- { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
+- { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
+- { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
+- { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
+- { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
+- { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
+- { CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */
+-
+- /* added based on MPlayer */
+- { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') },
+- { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
+- { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
+- { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
+- { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
+- { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') },
+-
+- { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
+-
+- { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
+- { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
+-
+- /* added based on MPlayer */
+- { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
+- { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') },
+- { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') },
+- { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') },
+- { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') },
+- { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') },
+- { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') },
+-
+- { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') },
+-
+- /* added based on MPlayer */
+- { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') },
+-
+- { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') },
+-
+- { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') },
+-
+- /* added based on MPlayer */
+- { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') },
+- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') },
+- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') },
+- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') },
+- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') },
+- { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') },
+- { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') },
+- { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') },
+- { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') },
+- { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') },
+- { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
+- { CODEC_ID_MPEG1VIDEO, 0x10000001 },
+- { CODEC_ID_MPEG2VIDEO, 0x10000002 },
+- { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
+- { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') },
+- { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
+- { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
+- { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
+- { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */
+- { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */
+- { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
+- { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
+- { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') },
+- { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
+- { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
+- { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
+- { CODEC_ID_RAWVIDEO, 0 },
+- { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
+- { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') },
+- { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
+- { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') },
+- { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
+- { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
+- { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
+- { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
+- { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
+- { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
+- { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
+- { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
+- { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
+- { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
+- { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
+- { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
+- { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
+- { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
+- { CODEC_ID_MSRLE, MKTAG(0x1, 0x0, 0x0, 0x0) },
+- { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
+- { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
+- { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
+- { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
+- { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
+- { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
+- { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
+- { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
+- { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
+- { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
+- { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
+- { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
+- { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
+- { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
+- { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
+- { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
+- { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
+- { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
+- { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
+- { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
+- { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
+- { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
+- { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
+-#if LIBAVCODEC_VERSION_INT>0x000409
+- { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
+- { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
+- { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') },
+- { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
+- { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
+-#endif
+-#if LIBAVCODEC_VERSION_INT>((50<<16)+(1<<8)+0)
+- { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') },
+- { CODEC_ID_JPEGLS,MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */
+- { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
+- { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
+- { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
+- { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') },
+- { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') },
+-#endif
+-#if LIBAVCODEC_VERSION_INT>((51<<16)+(11<<8)+0)
+- { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
+- { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
+- { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
+- { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
+- { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
+- { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
+- { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
+-#endif
+-#if LIBAVCODEC_VERSION_INT>=((51<<16)+(49<<8)+0)
+-// this tag seems not to exist in older versions of FFMPEG
+- { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
+-#endif
+- { CODEC_ID_NONE, 0 },
+-};
+--
+1.9.3
+
diff --git a/recipes-support/opencv/opencv/0003-cap_ffmpeg-wrap-a-forgotten-instance-of-CODEC_ID_H26.patch b/recipes-support/opencv/opencv/0003-cap_ffmpeg-wrap-a-forgotten-instance-of-CODEC_ID_H26.patch
new file mode 100644
index 0000000..a0b9d19
--- /dev/null
+++ b/recipes-support/opencv/opencv/0003-cap_ffmpeg-wrap-a-forgotten-instance-of-CODEC_ID_H26.patch
@@ -0,0 +1,27 @@
+From cb16656555e6c66fc5aae304f46b9b472bac50aa Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton@khirnov.net>
+Date: Thu, 6 Feb 2014 09:45:54 +0100
+Subject: [PATCH 3/5] cap_ffmpeg: wrap a forgotten instance of CODEC_ID_H264 in
+ CV_CODEC()
+
+(cherry picked from commit 614c66d402e260ff4c8ae7eb132d1c498febdeb2)
+---
+ modules/highgui/src/cap_ffmpeg_impl.hpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp
+index 068642a..e2e3c30 100644
+--- a/modules/highgui/src/cap_ffmpeg_impl.hpp
++++ b/modules/highgui/src/cap_ffmpeg_impl.hpp
+@@ -1119,7 +1119,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 == CV_CODEC(CODEC_ID_H264)) {
+ c->gop_size = -1;
+ c->qmin = -1;
+ c->bit_rate = 0;
+--
+1.9.3
+
diff --git a/recipes-support/opencv/opencv/0004-cap_ffmpeg-do-not-use-AVStream.r_frame_rate.patch b/recipes-support/opencv/opencv/0004-cap_ffmpeg-do-not-use-AVStream.r_frame_rate.patch
new file mode 100644
index 0000000..5d4584a
--- /dev/null
+++ b/recipes-support/opencv/opencv/0004-cap_ffmpeg-do-not-use-AVStream.r_frame_rate.patch
@@ -0,0 +1,47 @@
+From 023e48e2e2fe845128752c4eeb9d0aa26b261e89 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton@khirnov.net>
+Date: Thu, 6 Feb 2014 09:46:58 +0100
+Subject: [PATCH 4/5] cap_ffmpeg: do not use AVStream.r_frame_rate
+
+r_frame_rate is a guessed number defined as "the least common multiple
+of all framerates in the stream". It has been deprecated and removed in
+new Libav releases.
+
+Use avg_frame_rate instead, which is the average framerate of the
+stream.
+
+(cherry picked from commit 0c8faf17694baaf62ad120b6b3103b5d022e04ed)
+---
+ modules/highgui/src/cap_ffmpeg_impl.hpp | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp
+index e2e3c30..44ef553 100644
+--- a/modules/highgui/src/cap_ffmpeg_impl.hpp
++++ b/modules/highgui/src/cap_ffmpeg_impl.hpp
+@@ -735,7 +735,7 @@ double CvCapture_FFMPEG::getProperty( int property_id )
+ case CV_FFMPEG_CAP_PROP_FRAME_HEIGHT:
+ return (double)frame.height;
+ case CV_FFMPEG_CAP_PROP_FPS:
+- return av_q2d(video_st->r_frame_rate);
++ return av_q2d(video_st->avg_frame_rate);
+ case CV_FFMPEG_CAP_PROP_FOURCC:
+ return (double)video_st->codec->codec_tag;
+ default:
+@@ -774,12 +774,7 @@ int CvCapture_FFMPEG::get_bitrate()
+
+ double CvCapture_FFMPEG::get_fps()
+ {
+- double fps = r2d(ic->streams[video_stream]->r_frame_rate);
+-
+- if (fps < eps_zero)
+- {
+- fps = r2d(ic->streams[video_stream]->avg_frame_rate);
+- }
++ double fps = r2d(ic->streams[video_stream]->avg_frame_rate);
+
+ if (fps < eps_zero)
+ {
+--
+1.9.3
+
diff --git a/recipes-support/opencv/opencv/0005-cap_ffmpeg-use-avcodec_encode_video2-where-available.patch b/recipes-support/opencv/opencv/0005-cap_ffmpeg-use-avcodec_encode_video2-where-available.patch
new file mode 100644
index 0000000..71c5001
--- /dev/null
+++ b/recipes-support/opencv/opencv/0005-cap_ffmpeg-use-avcodec_encode_video2-where-available.patch
@@ -0,0 +1,80 @@
+From aecaa02aba9f1b4e356127b458e464d1feacf599 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton@khirnov.net>
+Date: Thu, 6 Feb 2014 10:08:17 +0100
+Subject: [PATCH 5/5] cap_ffmpeg: use avcodec_encode_video2() where available
+
+avcodec_encode_video() has been deprecated and removed in newer
+libavcodec versions.
+
+(cherry picked from commit 8dbc0ac766f2342bd3004a1459012f65004042a6)
+---
+ modules/highgui/src/cap_ffmpeg_impl.hpp | 44 +++++++++++++++++++++++----------
+ 1 file changed, 31 insertions(+), 13 deletions(-)
+
+diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp
+index 44ef553..4ac2f84 100644
+--- a/modules/highgui/src/cap_ffmpeg_impl.hpp
++++ b/modules/highgui/src/cap_ffmpeg_impl.hpp
+@@ -1136,7 +1136,6 @@ static const int OPENCV_NO_FRAMES_WRITTEN_CODE = 1000;
+ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_t * outbuf, uint32_t outbuf_size, AVFrame * picture )
+ {
+ AVCodecContext * c = video_st->codec;
+- int out_size;
+ int ret = 0;
+
+ if (oc->oformat->flags & AVFMT_RAWPICTURE) {
+@@ -1156,20 +1155,39 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
+
+ ret = av_write_frame(oc, &pkt);
+ } else {
++ AVPacket pkt;
++ int got_output;
++
++ av_init_packet(&pkt);
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 1, 0)
+ /* 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(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->key_frame)
+- pkt.flags |= PKT_FLAG_KEY;
++ int out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
++ got_output = out_size > 0;
++ pkt.data = outbuf;
++ pkt.size = out_size;
++ if(c->coded_frame->pts != (int64_t)AV_NOPTS_VALUE)
++ pkt.pts = c->coded_frame->pts;
++ pkt.dts = AV_NOPTS_VALUE;
++ if(c->coded_frame->key_frame)
++ pkt.flags |= PKT_FLAG_KEY;
++#else
++ pkt.data = NULL;
++ pkt.size = 0;
++
++ ret = avcodec_encode_video2(c, &pkt, picture, &got_output);
++ if (ret < 0)
++ got_output = 0;
++#endif
++
++ if (got_output) {
++ if (pkt.pts != (int64_t)AV_NOPTS_VALUE)
++ pkt.pts = av_rescale_q(pkt.pts, c->time_base, video_st->time_base);
++ if (pkt.dts != (int64_t)AV_NOPTS_VALUE)
++ pkt.dts = av_rescale_q(pkt.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;
+- pkt.data= outbuf;
+- pkt.size= out_size;
+
+ /* write the compressed frame in the media file */
+ ret = av_write_frame(oc, &pkt);
+--
+1.9.3
+
diff --git a/recipes-support/opencv/opencv_2.4.bbappend b/recipes-support/opencv/opencv_2.4.bbappend
new file mode 100644
index 0000000..814e0bd
--- /dev/null
+++ b/recipes-support/opencv/opencv_2.4.bbappend
@@ -0,0 +1,14 @@
+# libav 9.x -> 10.x changed/deprecated some of it's API
+# opencv 4.8.9 is not yet ready for this, the patches address the issues
+# They are taken from here:
+# https://github.com/Itseez/opencv/pull/2293
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/opencv:"
+
+SRC_URI += " \
+ file://0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch \
+ file://0002-cap_ffmpeg-drop-the-local-copy-of-the-RIFF-FourCC-li.patch \
+ file://0003-cap_ffmpeg-wrap-a-forgotten-instance-of-CODEC_ID_H26.patch \
+ file://0004-cap_ffmpeg-do-not-use-AVStream.r_frame_rate.patch \
+ file://0005-cap_ffmpeg-use-avcodec_encode_video2-where-available.patch \
+"