Home > Linux > Compiling old codes using new ffmpeg libraries

Compiling old codes using new ffmpeg libraries

FFMPEG libraries update fairly often. And there are many functions and keywords never used in the new version. I just failed to compile some codes with old ffmpeg functions. In this case, a few modifications are needed. Keywords are deprecated and have to be updated.

#define CodecType AVMediaType
#define CODEC_TYPE_UNKNOWN    AVMEDIA_TYPE_UNKNOWN
#define CODEC_TYPE_VIDEO      AVMEDIA_TYPE_VIDEO
#define CODEC_TYPE_AUDIO      AVMEDIA_TYPE_AUDIO
#define CODEC_TYPE_DATA       AVMEDIA_TYPE_DATA
#define CODEC_TYPE_SUBTITLE   AVMEDIA_TYPE_SUBTITLE
#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
#define CODEC_TYPE_NB         AVMEDIA_TYPE_NB
#define PKT_FLAG_KEY AV_PKT_FLAG_KEY

avcodec_decode_video is deprecated in the new version and avcodec_decode_video2 should be used.

int avcodec_decode_video(
        AVCodecContext* avctx,
        AVFrame* picture,
        int* got_picture_ptr,
        uint8_t* buf,
        int buf_size) {
    AVPacket pkt;
    av_init_packet(&pkt);
    pkt.data = buf;
    pkt.size = buf_size;
    return avcodec_decode_video2(avctx, picture, got_picture_ptr, &pkt);
}
Advertisements
Categories: Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: