Skip to content
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

Fix FFmpeg 6.0 crashes when loading 50+ clips and stressing the timeline #484

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
33 changes: 20 additions & 13 deletions src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5467,19 +5467,26 @@ MovieFFMpegIO::MovieFFMpegIO(CodecFilterFunction codecFilter,
sdparams);
}

if (!globalContextPool)
{
int poolSize = 500;
if (const char* c = getenv("TWK_MOVIEFFMPEG_CONTEXT_POOL_SIZE"))
{
poolSize = atoi(c);
}
if (poolSize > 0) globalContextPool = new ContextPool(poolSize);
else
{
report("Disabling mio_ffmpeg context thread pool.", true);
}
}
// Note : No longer using the global context pool (since FFmpeg 6.0)
// Rationale: The global context pool was based on the premise that a context
// could be opened and closed multiple times.
// However, with FFmpeg 6.0, this premise is no longer valid and was causing crashes.
// As per the FFmpeg 6 documentation: https://ffmpeg.org/doxygen/trunk/deprecated.html:
// "Opening and closing a codec context multiple times is not supported anymore – use multiple codec contexts instead."

// if (!globalContextPool)
// {
// int poolSize = 500;
// if (const char* c = getenv("TWK_MOVIEFFMPEG_CONTEXT_POOL_SIZE"))
// {
// int poolSize = atoi(c);
// }
// if (poolSize > 0) globalContextPool = new ContextPool(poolSize);
// else
// {
// report("Disabling mio_ffmpeg context thread pool.", true);
// }
// }
}

MovieFFMpegIO::~MovieFFMpegIO()
Expand Down