From 0470a1d8add492248c89ed843c22e98bc0047667 Mon Sep 17 00:00:00 2001 From: squall-leonhart Date: Mon, 17 Jun 2013 04:05:37 +0000 Subject: [PATCH] commiting Tim Harders patch for libav/ffmpeg --- src/common/ffmpeg.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/common/ffmpeg.cpp b/src/common/ffmpeg.cpp index c0ec5846..3c67e40e 100644 --- a/src/common/ffmpeg.cpp +++ b/src/common/ffmpeg.cpp @@ -93,7 +93,11 @@ MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fm return MRET_OK; AVCodecContext *ctx; +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,10,0) aud_st = av_new_stream(oc, 1); +#else + aud_st = avformat_new_stream(oc, NULL); +#endif if(!aud_st) { avformat_free_context(oc); oc = NULL; @@ -112,7 +116,11 @@ MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fm ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; AVCodec *codec = avcodec_find_encoder(fmt->audio_codec); +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,6,0) if(!codec || avcodec_open(ctx, codec)) { +#else + if(!codec || avcodec_open2(ctx, codec, NULL)) { +#endif avformat_free_context(oc); oc = NULL; return MRET_ERR_NOCODEC; @@ -124,7 +132,11 @@ MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fm MediaRet MediaRecorder::setup_video_stream(const char *fname, int w, int h, int d) { AVCodecContext *ctx; +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,10,0) vid_st = av_new_stream(oc, 0); +#else + vid_st = avformat_new_stream(oc, NULL); +#endif if(!vid_st) { avformat_free_context(oc); oc = NULL; @@ -203,7 +215,11 @@ MediaRet MediaRecorder::setup_video_stream(const char *fname, int w, int h, int ctx->pix_fmt = dp; } } +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,6,0) if(!codec || avcodec_open(ctx, codec)) { +#else + if(!codec || avcodec_open2(ctx, codec, NULL)) { +#endif avformat_free_context(oc); oc = NULL; return MRET_ERR_NOCODEC;