Skip to content

Commit

Permalink
Update videostreamsdata.cpp
Browse files Browse the repository at this point in the history
Set max threads to 16 for ffmpeg

Fix #128
  • Loading branch information
rodlie committed Mar 21, 2024
1 parent 80b9413 commit 5404439
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/FileCacheHandlers/videostreamsdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ void VideoStreamsData::open(const char * const path) {

fCodecContext = avcodec_alloc_context3(vidCodec);
if(!fCodecContext) RuntimeThrow("Error allocating AVCodecContext");
fCodecContext->thread_count = QThread::idealThreadCount() - 1;
int maxThreads = QThread::idealThreadCount() - 1;
// we set max threads to 16, beyond that ffmpeg will complain and there might be issues
fCodecContext->thread_count = maxThreads > 16 ? 16 : maxThreads;
if(avcodec_parameters_to_context(fCodecContext, vidCodecPars) < 0) {
RuntimeThrow("Failed to copy codec params to codec context");
}
Expand Down

0 comments on commit 5404439

Please sign in to comment.