diff --git a/CMakeLists.txt b/CMakeLists.txt index 616bfd36c..489b76a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -443,6 +443,7 @@ find_package(FFMPEG REQUIRED avcodec avformat avutil + swresample swscale) set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS}) @@ -458,16 +459,6 @@ else() set(optlibsnotfound "${optlibsnotfound} AVDevice") endif() -find_package(FFMPEG COMPONENTS swresample) -if(FFMPEG_swresample_FOUND) - set(HAVE_LIBSWRESAMPLE 1) - set(HAVE_LIBSWRESAMPLE_SWRESAMPLE_H 1) - list(APPEND ZM_BIN_LIBS "FFMPEG::swresample") - set(optlibsfound "${optlibsfound} SWResample") -else() - set(optlibsnotfound "${optlibsnotfound} SWResample") -endif() - set(PATH_FFMPEG "") set(OPT_FFMPEG "no") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89eb6924b..82f6cefe0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,6 +80,7 @@ target_link_libraries(zm FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil + FFMPEG::swresample FFMPEG::swscale libbcrypt::bcrypt RtspServer::RtspServer diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index ee3649618..431f64c33 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -635,7 +635,6 @@ void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRat av_packet_rescale_ts(opkt, src_tb, dst_tb); } -#if defined(HAVE_LIBSWRESAMPLE) int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_frame) { if (in_frame) { // Resample the in_frame into the audioSampleBuffer until we process the whole @@ -659,7 +658,6 @@ int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_ int zm_resample_get_delay(SwrContext *resample_ctx, int time_base) { return swr_get_delay(resample_ctx, time_base); } -#endif int zm_add_samples_to_fifo(AVAudioFifo *fifo, AVFrame *frame) { int ret = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame->nb_samples); diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index b0f612285..53076589d 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -24,21 +24,18 @@ #include "zm_define.h" extern "C" { - -#ifdef HAVE_LIBSWRESAMPLE -#include "libswresample/swresample.h" -#endif +#include // AVUTIL -#include "libavutil/avassert.h" +#include #include #include #include #include -#include "libavutil/audio_fifo.h" -#include "libavutil/imgutils.h" +#include +#include #if HAVE_LIBAVUTIL_HWCONTEXT_H - #include "libavutil/hwcontext.h" + #include #endif /* LIBAVUTIL_VERSION_CHECK checks for the right version of libav and FFmpeg @@ -411,10 +408,8 @@ int zm_send_frame_receive_packet(AVCodecContext *context, AVFrame *frame, AVPack void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRational src_tb, const AVRational dst_tb); -#if defined(HAVE_LIBSWRESAMPLE) int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_frame); int zm_resample_get_delay(SwrContext *resample_ctx, int time_base); -#endif int zm_add_samples_to_fifo(AVAudioFifo *fifo, AVFrame *frame); int zm_get_samples_from_fifo(AVAudioFifo *fifo, AVFrame *frame); diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index b72ff4968..af2ba8444 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -87,10 +87,8 @@ VideoStore::VideoStore( packets_written(0), frame_count(0), hw_device_ctx(nullptr), -#if defined(HAVE_LIBSWRESAMPLE) resample_ctx(nullptr), fifo(nullptr), -#endif converted_in_samples(nullptr), filename(filename_in), format(format_in), @@ -722,7 +720,6 @@ VideoStore::~VideoStore() { #endif } -#if defined(HAVE_LIBSWRESAMPLE) if (resample_ctx) { if (fifo) { av_audio_fifo_free(fifo); @@ -742,7 +739,6 @@ VideoStore::~VideoStore() { av_free(converted_in_samples); converted_in_samples = nullptr; } -#endif } // end if audio_out_stream Debug(4, "free context"); @@ -753,10 +749,6 @@ VideoStore::~VideoStore() { } // VideoStore::~VideoStore() bool VideoStore::setup_resampler() { -#if !defined(HAVE_LIBSWRESAMPLE) - Error("Not built with resample library. Cannot do audio conversion to AAC"); - return false; -#else int ret; #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) @@ -925,7 +917,6 @@ bool VideoStore::setup_resampler() { Error("Could not allocate FIFO"); return false; } -#if defined(HAVE_LIBSWRESAMPLE) resample_ctx = swr_alloc_set_opts(nullptr, audio_out_ctx->channel_layout, audio_out_ctx->sample_fmt, @@ -948,7 +939,6 @@ bool VideoStore::setup_resampler() { return false; } Debug(1,"Success setting up SWRESAMPLE"); -#endif out_frame->nb_samples = audio_out_ctx->frame_size; out_frame->format = audio_out_ctx->sample_fmt; @@ -984,7 +974,6 @@ bool VideoStore::setup_resampler() { } return true; -#endif } // end bool VideoStore::setup_resampler() int VideoStore::writePacket(const std::shared_ptr &ipkt) { diff --git a/src/zm_videostore.h b/src/zm_videostore.h index 467f85545..580607959 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -9,12 +9,10 @@ #include extern "C" { -#ifdef HAVE_LIBSWRESAMPLE -#include "libswresample/swresample.h" -#endif -#include "libavutil/audio_fifo.h" +#include +#include #if HAVE_LIBAVUTIL_HWCONTEXT_H -#include "libavutil/hwcontext.h" +#include #endif } @@ -70,10 +68,8 @@ class VideoStore { AVBufferRef *hw_device_ctx; -#ifdef HAVE_LIBSWRESAMPLE SwrContext *resample_ctx; AVAudioFifo *fifo; -#endif uint8_t *converted_in_samples; const char *filename; diff --git a/zoneminder-config.cmake b/zoneminder-config.cmake index 89add0950..a46587daf 100644 --- a/zoneminder-config.cmake +++ b/zoneminder-config.cmake @@ -37,8 +37,6 @@ #cmakedefine HAVE_LIBAVDEVICE 1 #cmakedefine HAVE_LIBAVDEVICE_AVDEVICE_H 1 #cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_H 1 -#cmakedefine HAVE_LIBSWRESAMPLE 1 -#cmakedefine HAVE_LIBSWRESAMPLE_SWRESAMPLE_H 1 #cmakedefine HAVE_LIBVLC 1 #cmakedefine HAVE_VLC_VLC_H 1 #cmakedefine HAVE_LIBVNC 1