diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index f9f2a1919..ae30ffd77 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -440,7 +440,7 @@ int zm_send_frame_receive_packet(AVCodecContext *ctx, AVFrame *frame, AVPacket & void zm_free_codec(AVCodecContext **ctx) { if (*ctx) { - avcodec_close(*ctx); + //avcodec_close(*ctx); // We allocate and copy in newer ffmpeg, so need to free it avcodec_free_context(ctx); *ctx = nullptr; diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 41dbc63b9..860f8cd25 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -621,14 +621,14 @@ int FfmpegCamera::Close() { mLastAudioPTS = 0; if (mVideoCodecContext) { - avcodec_close(mVideoCodecContext); + //avcodec_close(mVideoCodecContext); avcodec_free_context(&mVideoCodecContext); mVideoCodecContext = nullptr; } if (mAudioCodecContext and !mSecondInput) { // If second input, then these will get freed in FFmpeg_Input's destructor - avcodec_close(mAudioCodecContext); + //avcodec_close(mAudioCodecContext); avcodec_free_context(&mAudioCodecContext); mAudioCodecContext = nullptr; } diff --git a/src/zm_ffmpeg_input.cpp b/src/zm_ffmpeg_input.cpp index 2f18158cd..bf68114d9 100644 --- a/src/zm_ffmpeg_input.cpp +++ b/src/zm_ffmpeg_input.cpp @@ -123,7 +123,7 @@ int FFmpeg_Input::Open(const char *filepath) { int FFmpeg_Input::Close( ) { if (streams) { for (unsigned int i = 0; i < input_format_context->nb_streams; i += 1) { - avcodec_close(streams[i].context); + //avcodec_close(streams[i].context); avcodec_free_context(&streams[i].context); streams[i].context = nullptr; } diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index c4838d3e2..a83766571 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -369,7 +369,8 @@ VideoStream::~VideoStream( ) { /* close each codec */ if ( ost ) { - avcodec_close( codec_context ); + //avcodec_close( codec_context ); + avcodec_free_context(&codec_context); av_free( video_outbuf ); } diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index f5414f87b..501d9aa49 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -86,7 +86,8 @@ RemoteCameraRtsp::RemoteCameraRtsp( RemoteCameraRtsp::~RemoteCameraRtsp() { if ( mVideoCodecContext ) { - avcodec_close(mVideoCodecContext); + //avcodec_close(mVideoCodecContext); + avcodec_free_context(&mVideoCodecContext); mVideoCodecContext = nullptr; // Freed by avformat_free_context in the destructor of RtspThread class } // Is allocated in RTSPThread and is free there as well diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 1f302fc4d..ae6195b4d 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -779,7 +779,7 @@ VideoStore::~VideoStore() { video_in_ctx = nullptr; if (video_out_ctx) { - avcodec_close(video_out_ctx); + //avcodec_close(video_out_ctx); Debug(3, "Freeing video_out_ctx"); avcodec_free_context(&video_out_ctx); if (hw_device_ctx) { @@ -791,13 +791,13 @@ VideoStore::~VideoStore() { if (audio_out_stream) { audio_in_codec = nullptr; if (audio_in_ctx) { - avcodec_close(audio_in_ctx); + //avcodec_close(audio_in_ctx); avcodec_free_context(&audio_in_ctx); } if (audio_out_ctx) { Debug(4, "Success closing audio_out_ctx"); - avcodec_close(audio_out_ctx); + //avcodec_close(audio_out_ctx); avcodec_free_context(&audio_out_ctx); }