Skip to content

Commit 66adcab

Browse files
Merge pull request #4131 from SteveGilvarry/ffmpeg7-avcodec_close
Removing avcodec_close, avcodec_free_context is replacement and been …
2 parents 81983f4 + 8822710 commit 66adcab

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

src/zm_ffmpeg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ int zm_send_frame_receive_packet(AVCodecContext *ctx, AVFrame *frame, AVPacket &
440440

441441
void zm_free_codec(AVCodecContext **ctx) {
442442
if (*ctx) {
443-
avcodec_close(*ctx);
443+
//avcodec_close(*ctx);
444444
// We allocate and copy in newer ffmpeg, so need to free it
445445
avcodec_free_context(ctx);
446446
*ctx = nullptr;

src/zm_ffmpeg_camera.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,14 +621,14 @@ int FfmpegCamera::Close() {
621621
mLastAudioPTS = 0;
622622

623623
if (mVideoCodecContext) {
624-
avcodec_close(mVideoCodecContext);
624+
//avcodec_close(mVideoCodecContext);
625625
avcodec_free_context(&mVideoCodecContext);
626626
mVideoCodecContext = nullptr;
627627
}
628628

629629
if (mAudioCodecContext and !mSecondInput) {
630630
// If second input, then these will get freed in FFmpeg_Input's destructor
631-
avcodec_close(mAudioCodecContext);
631+
//avcodec_close(mAudioCodecContext);
632632
avcodec_free_context(&mAudioCodecContext);
633633
mAudioCodecContext = nullptr;
634634
}

src/zm_ffmpeg_input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int FFmpeg_Input::Open(const char *filepath) {
123123
int FFmpeg_Input::Close( ) {
124124
if (streams) {
125125
for (unsigned int i = 0; i < input_format_context->nb_streams; i += 1) {
126-
avcodec_close(streams[i].context);
126+
//avcodec_close(streams[i].context);
127127
avcodec_free_context(&streams[i].context);
128128
streams[i].context = nullptr;
129129
}

src/zm_mpeg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ VideoStream::~VideoStream( ) {
369369

370370
/* close each codec */
371371
if ( ost ) {
372-
avcodec_close( codec_context );
372+
//avcodec_close( codec_context );
373+
avcodec_free_context(&codec_context);
373374
av_free( video_outbuf );
374375
}
375376

src/zm_remote_camera_rtsp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ RemoteCameraRtsp::RemoteCameraRtsp(
8686
RemoteCameraRtsp::~RemoteCameraRtsp() {
8787

8888
if ( mVideoCodecContext ) {
89-
avcodec_close(mVideoCodecContext);
89+
//avcodec_close(mVideoCodecContext);
90+
avcodec_free_context(&mVideoCodecContext);
9091
mVideoCodecContext = nullptr; // Freed by avformat_free_context in the destructor of RtspThread class
9192
}
9293
// Is allocated in RTSPThread and is free there as well

src/zm_videostore.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ VideoStore::~VideoStore() {
779779
video_in_ctx = nullptr;
780780

781781
if (video_out_ctx) {
782-
avcodec_close(video_out_ctx);
782+
//avcodec_close(video_out_ctx);
783783
Debug(3, "Freeing video_out_ctx");
784784
avcodec_free_context(&video_out_ctx);
785785
if (hw_device_ctx) {
@@ -791,13 +791,13 @@ VideoStore::~VideoStore() {
791791
if (audio_out_stream) {
792792
audio_in_codec = nullptr;
793793
if (audio_in_ctx) {
794-
avcodec_close(audio_in_ctx);
794+
//avcodec_close(audio_in_ctx);
795795
avcodec_free_context(&audio_in_ctx);
796796
}
797797

798798
if (audio_out_ctx) {
799799
Debug(4, "Success closing audio_out_ctx");
800-
avcodec_close(audio_out_ctx);
800+
//avcodec_close(audio_out_ctx);
801801
avcodec_free_context(&audio_out_ctx);
802802
}
803803

0 commit comments

Comments
 (0)