From 2879458e9824bfbccdb24256d08e885bda695096 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 2 Jan 2015 23:24:44 +0100 Subject: [PATCH] Fix for issue #62 (slow internet streams), credit @chme --- configure.ac | 2 +- src/artwork.c | 2 +- src/filescanner_ffmpeg.c | 9 +++++++++ src/transcode.c | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 136dec2a..0632255c 100644 --- a/configure.ac +++ b/configure.ac @@ -163,7 +163,7 @@ dnl Check for av_lock_manager (ffmpeg >= 0.5.1) AC_CHECK_LIB([avcodec], [av_lockmgr_register], , AC_MSG_ERROR([libav (ffmpeg) >= 0.5.1 required])) dnl Check for avcodec_find_best_pix_fmt_of_list (is only in ffmpeg, not libav) AC_CHECK_LIB([avcodec], [avcodec_find_best_pix_fmt_of_list], - AC_DEFINE(FFMPEG_INCOMPATIBLE_API, 1, [Define to 1 if you have ffmpeg (and not libav).])) + AC_DEFINE(HAVE_FFMPEG, 1, [Define to 1 if you have ffmpeg (and not libav).])) LIBS="$save_LIBS" # Check for libavformat >= 53; url -> avio switch diff --git a/src/artwork.c b/src/artwork.c index 2f87f122..94e04ff3 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -314,7 +314,7 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, struct ev #endif #if LIBAVCODEC_VERSION_MAJOR >= 55 || (LIBAVCODEC_VERSION_MAJOR == 54 && LIBAVCODEC_VERSION_MINOR >= 35) -# ifndef FFMPEG_INCOMPATIBLE_API +# ifndef HAVE_FFMPEG dst->pix_fmt = avcodec_find_best_pix_fmt2((enum AVPixelFormat *)img_encoder->pix_fmts, src->pix_fmt, 1, NULL); # else dst->pix_fmt = avcodec_find_best_pix_fmt_of_list((enum AVPixelFormat *)img_encoder->pix_fmts, src->pix_fmt, 1, NULL); diff --git a/src/filescanner_ffmpeg.c b/src/filescanner_ffmpeg.c index cec6b1ae..c70a2530 100644 --- a/src/filescanner_ffmpeg.c +++ b/src/filescanner_ffmpeg.c @@ -415,6 +415,15 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi) options = NULL; #if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3) +# ifndef HAVE_FFMPEG + // Without this, libav is slow to probe some internet streams + if (mfi->data_kind == 1) + { + ctx = avformat_alloc_context(); + ctx->probesize = 64000; + } +# endif + if (mfi->data_kind == 1) av_dict_set(&options, "icy", "1", 0); diff --git a/src/transcode.c b/src/transcode.c index c6eacdd0..a1269c0b 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -498,6 +498,15 @@ transcode_setup(struct transcode_ctx **nctx, struct media_file_info *mfi, off_t memset(ctx, 0, sizeof(struct transcode_ctx)); #if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3) +# ifndef HAVE_FFMPEG + // Without this, libav is slow to probe some internet streams, which leads to RAOP timeouts + if (mfi->data_kind == 1) + { + ctx->fmtctx = avformat_alloc_context(); + ctx->fmtctx->probesize = 64000; + } +# endif + ret = avformat_open_input(&ctx->fmtctx, mfi->path, NULL, NULL); #else ret = av_open_input_file(&ctx->fmtctx, mfi->path, NULL, 0, NULL);