Skip to content

VideoProperties: fix ghost threads when call analyseGopStructure #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/AvTranscoder/properties/VideoProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,16 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
_codecContext->skip_frame = AVDISCARD_NONE;

AVPacket pkt;
av_init_packet(&pkt);

// Allocate frame
#if LIBAVCODEC_VERSION_MAJOR > 54
AVFrame* frame = av_frame_alloc();
#else
AVFrame* frame = avcodec_alloc_frame();
#endif

av_init_packet(&pkt);
// Initialize the AVCodecContext to use the given AVCodec
avcodec_open2(_codecContext, _codec, NULL);

int count = 0;
Expand Down Expand Up @@ -531,6 +533,11 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
if(stopAnalyse)
break;
}

// Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself)
avcodec_close(_codecContext);

// Free frame
#if LIBAVCODEC_VERSION_MAJOR > 54
av_frame_free(&frame);
#else
Expand Down