1 diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c
2 index ef7a05f..f2c5c94 100644
3 --- a/src/plugins/thumbnailffmpeg_extractor.c
4 +++ b/src/plugins/thumbnailffmpeg_extractor.c
5 @@ -181,7 +181,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
7 AVCodecContext *encoder_codec_ctx;
9 - AVCodec *encoder_codec;
10 + const AVCodec *encoder_codec;
11 struct SwsContext *scaler_ctx;
14 @@ -332,12 +332,12 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
15 dst_frame->quality = encoder_codec_ctx->global_quality;
18 - err = avcodec_encode_video2 (encoder_codec_ctx,
20 - dst_frame, &gotPacket);
22 + err = avcodec_send_frame(encoder_codec_ctx, dst_frame);
25 + err = avcodec_receive_packet(encoder_codec_ctx, &pkt);
26 + if (err < 0 && err != AVERROR(EAGAIN))
29 memcpy (encoder_output_buffer,pkt.data, pkt.size);
31 @@ -417,7 +417,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
34 AVCodecContext *codec_ctx;
36 + const AVCodec *codec;
39 uint8_t *encoded_thumbnail;
40 @@ -480,7 +480,14 @@ extract_image (ENUM_CODEC_ID image_codec_id,
41 av_init_packet (&avpkt);
42 avpkt.data = padded_data;
44 - avcodec_decode_video2 (codec_ctx, frame, &frame_finished, &avpkt);
45 + int ret = avcodec_send_packet(codec_ctx, &avpkt);
48 + ret = avcodec_receive_frame(codec_ctx, frame);
49 + if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
56 @@ -553,7 +560,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
57 struct AVFormatContext *format_ctx;
58 AVCodecContext *codec_ctx;
59 AVCodecParameters *codecpar;
61 + const AVCodec *codec;
62 AVDictionary *options;
64 uint8_t *encoded_thumbnail;
65 @@ -607,7 +614,8 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
66 for (i = 0; i<format_ctx->nb_streams; i++)
68 codecpar = format_ctx->streams[i]->codecpar;
69 - codec_ctx = format_ctx->streams[i]->codec;
70 + codec_ctx = avcodec_alloc_context3(avcodec_find_decoder(codecpar->codec_id));
71 + avcodec_parameters_to_context(codec_ctx, codecpar);
72 if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type)
74 if (NULL == (codec = avcodec_find_decoder (codecpar->codec_id)))
75 @@ -682,10 +690,14 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
77 if (packet.stream_index == video_stream_index)
79 - avcodec_decode_video2 (codec_ctx,
83 + int ret = avcodec_send_packet(codec_ctx, &packet);
86 + ret = avcodec_receive_frame(codec_ctx, frame);
87 + if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
91 if (frame_finished && frame->key_frame)
93 av_packet_unref (&packet);