diff -ur zoneminder-1.36.36.org/src/zm_ffmpeg_camera.cpp zoneminder-1.36.36/src/zm_ffmpeg_camera.cpp --- zoneminder-1.36.36.org/src/zm_ffmpeg_camera.cpp 2025-10-29 14:45:26.933191973 +0100 +++ zoneminder-1.36.36/src/zm_ffmpeg_camera.cpp 2025-11-05 14:31:49.843777440 +0100 @@ -595,14 +595,18 @@ mCanCapture = false; if ( mVideoCodecContext ) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close(mVideoCodecContext); +#endif #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avcodec_free_context(&mVideoCodecContext); #endif mVideoCodecContext = nullptr; // Freed by av_close_input_file } if ( mAudioCodecContext ) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close(mAudioCodecContext); +#endif #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avcodec_free_context(&mAudioCodecContext); #endif diff -ur zoneminder-1.36.36.org/src/zm_ffmpeg.cpp zoneminder-1.36.36/src/zm_ffmpeg.cpp --- zoneminder-1.36.36.org/src/zm_ffmpeg.cpp 2025-10-29 14:45:26.933191973 +0100 +++ zoneminder-1.36.36/src/zm_ffmpeg.cpp 2025-11-05 14:31:49.844198254 +0100 @@ -601,7 +601,9 @@ void zm_free_codec(AVCodecContext **ctx) { if (*ctx) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close(*ctx); +#endif #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) // We allocate and copy in newer ffmpeg, so need to free it avcodec_free_context(ctx); diff -ur zoneminder-1.36.36.org/src/zm_ffmpeg_input.cpp zoneminder-1.36.36/src/zm_ffmpeg_input.cpp --- zoneminder-1.36.36.org/src/zm_ffmpeg_input.cpp 2025-10-29 14:45:26.933191973 +0100 +++ zoneminder-1.36.36/src/zm_ffmpeg_input.cpp 2025-11-05 14:31:49.844690762 +0100 @@ -143,7 +143,9 @@ int FFmpeg_Input::Close( ) { if (streams) { for (unsigned int i = 0; i < input_format_context->nb_streams; i += 1) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close(streams[i].context); +#endif #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avcodec_free_context(&streams[i].context); streams[i].context = nullptr; diff -ur zoneminder-1.36.36.org/src/zm_mpeg.cpp zoneminder-1.36.36/src/zm_mpeg.cpp --- zoneminder-1.36.36.org/src/zm_mpeg.cpp 2025-10-29 14:45:26.933191973 +0100 +++ zoneminder-1.36.36/src/zm_mpeg.cpp 2025-11-05 14:31:49.844920280 +0100 @@ -498,7 +498,9 @@ } /* close each codec */ if ( ost ) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close( codec_context ); +#endif av_free( opicture->data[0] ); av_frame_free( &opicture ); if ( tmp_opicture ) { @@ -532,6 +534,9 @@ if ( codec_and_format ) { delete codec_and_format; } +#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) + avcodec_free_context(&codec_context); +#endif } double VideoStream::EncodeFrame( const uint8_t *buffer, int buffer_size, bool _add_timestamp, unsigned int _timestamp ) { diff -ur zoneminder-1.36.36.org/src/zm_remote_camera_rtsp.cpp zoneminder-1.36.36/src/zm_remote_camera_rtsp.cpp --- zoneminder-1.36.36.org/src/zm_remote_camera_rtsp.cpp 2025-10-29 14:45:26.933191973 +0100 +++ zoneminder-1.36.36/src/zm_remote_camera_rtsp.cpp 2025-11-05 14:33:07.185734189 +0100 @@ -84,8 +84,10 @@ RemoteCameraRtsp::~RemoteCameraRtsp() { if ( mVideoCodecContext ) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close(mVideoCodecContext); mVideoCodecContext = nullptr; // Freed by avformat_free_context in the destructor of RtspThread class +#endif } // Is allocated in RTSPThread and is free there as well mFormatContext = nullptr; @@ -93,6 +95,9 @@ if ( capture ) { Terminate(); } +#if LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) + avcodec_free_context(&mVideoCodecContext); +#endif } void RemoteCameraRtsp::Initialise() { diff -ur zoneminder-1.36.36.org/src/zm_videostore.cpp zoneminder-1.36.36/src/zm_videostore.cpp --- zoneminder-1.36.36.org/src/zm_videostore.cpp 2025-10-29 14:45:26.933887846 +0100 +++ zoneminder-1.36.36/src/zm_videostore.cpp 2025-11-05 14:31:49.845456830 +0100 @@ -754,8 +754,10 @@ if (video_out_stream) { video_in_ctx = nullptr; +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) avcodec_close(video_out_ctx); Debug(3, "Freeing video_out_ctx"); +#endif avcodec_free_context(&video_out_ctx); if (hw_device_ctx) { Debug(3, "Freeing hw_device_ctx"); @@ -772,8 +774,10 @@ audio_in_codec = nullptr; if (audio_out_ctx) { +#if !LIBAVCODEC_VERSION_CHECK(62, 11, 0, 11, 0) Debug(4, "Success closing audio_out_ctx"); avcodec_close(audio_out_ctx); +#endif #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avcodec_free_context(&audio_out_ctx); #endif