diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp index ec44548..9c48f96 100644 --- a/modules/highgui/src/cap_ffmpeg_impl.hpp +++ b/modules/highgui/src/cap_ffmpeg_impl.hpp @@ -468,7 +468,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) AVCodecContext *enc = &ic->streams[i]->codec; #endif - if( CODEC_TYPE_VIDEO == enc->codec_type && video_stream < 0) { + if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0) { AVCodec *codec = avcodec_find_decoder(enc->codec_id); if (!codec || avcodec_open(enc, codec) < 0) @@ -554,7 +554,11 @@ bool CvCapture_FFMPEG::grabFrame() continue; } -#if LIBAVFORMAT_BUILD > 4628 +#if LIBAVFORMAT_BUILD > 5223 + 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); @@ -813,16 +817,8 @@ protected: static const char * icvFFMPEGErrStr(int err) { 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; } @@ -906,7 +902,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, #endif #if LIBAVFORMAT_BUILD > 4621 - c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO); + c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); #else c->codec_id = oc->oformat->video_codec; #endif @@ -918,7 +914,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, //if(codec_tag) c->codec_tag=codec_tag; codec = avcodec_find_encoder(c->codec_id); - c->codec_type = CODEC_TYPE_VIDEO; + c->codec_type = AVMEDIA_TYPE_VIDEO; /* put sample parameters */ c->bit_rate = bitrate; @@ -1005,7 +1001,7 @@ int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_ AVPacket pkt; av_init_packet(&pkt); - pkt.flags |= PKT_FLAG_KEY; + pkt.flags |= AV_PKT_FLAG_KEY; pkt.stream_index= video_st->index; pkt.data= (uint8_t *)picture; pkt.size= sizeof(AVPicture); @@ -1025,7 +1021,7 @@ int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_ pkt.pts = c->coded_frame->pts; #endif if(c->coded_frame->key_frame) - pkt.flags |= PKT_FLAG_KEY; + pkt.flags |= AV_PKT_FLAG_KEY; pkt.stream_index= video_st->index; pkt.data= outbuf; pkt.size= out_size; @@ -1222,7 +1218,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, av_register_all (); /* auto detect the output format from the name and fourcc code. */ - fmt = guess_format(NULL, filename, NULL); + fmt = av_guess_format(NULL, filename, NULL); if (!fmt) return false; @@ -1245,7 +1241,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, #endif // alloc memory for context - oc = av_alloc_format_context(); + oc = avformat_alloc_context(); assert (oc); /* set file name */