--- a/src/ffmpeg.c +++ b/src/ffmpeg.c @@ -50,6 +50,10 @@ #include #include "ffmpeg.h" +#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 +#endif + #ifndef CODEC_TYPE_AUDIO #define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO #endif @@ -96,7 +100,7 @@ static int stream_component_open(priv_t enc->err_recognition = 1; #endif - if (!codec || avcodec_open(enc, codec) < 0) + if (!codec || avcodec_open2(enc, codec, NULL) < 0) return -1; if (enc->codec_type != AVMEDIA_TYPE_AUDIO) { lsx_fail("ffmpeg CODEC %x is not an audio CODEC", enc->codec_type); @@ -178,7 +182,7 @@ static int startread(sox_format_t * ft) } /* Get CODEC parameters */ - if ((ret = av_find_stream_info(ffmpeg->ctxt)) < 0) { + if ((ret = avformat_find_stream_info(ffmpeg->ctxt, NULL)) < 0) { lsx_fail("ffmpeg could not find CODEC parameters for %s", ft->filename); return SOX_EOF; } @@ -256,7 +260,7 @@ static int stopread(sox_format_t * ft) if (ffmpeg->audio_stream >= 0) stream_component_close(ffmpeg, ffmpeg->audio_stream); if (ffmpeg->ctxt) { - av_close_input_file(ffmpeg->ctxt); + avformat_close_input(&ffmpeg->ctxt); ffmpeg->ctxt = NULL; /* safety */ } @@ -267,16 +271,21 @@ static int stopread(sox_format_t * ft) /* * add an audio output stream */ +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0) +static AVStream *add_audio_stream(sox_format_t * ft, AVFormatContext *oc, enum AVCodecID codec_id) +#else static AVStream *add_audio_stream(sox_format_t * ft, AVFormatContext *oc, enum CodecID codec_id) +#endif { AVCodecContext *c; AVStream *st; - st = av_new_stream(oc, 1); + st = avformat_new_stream(oc, NULL); if (!st) { lsx_fail("ffmpeg could not alloc stream"); return NULL; } + st->id = 1; c = st->codec; c->codec_id = codec_id; @@ -306,7 +315,7 @@ static int open_audio(priv_t * ffmpeg, A } /* open it */ - if (avcodec_open(c, codec) < 0) { + if (avcodec_open2(c, codec, NULL) < 0) { lsx_fail("ffmpeg could not open CODEC"); return SOX_EOF; }