Can I make this kind of setting?
_pCodecContext->thread_count = threadCount <= 0 ? Environment.ProcessorCount : threadCount;
_pCodecContext->thread_type = ffmpeg.FF_THREAD_SLICE;
I noticed DecoderThreads, but this is ineffective because multithreading requires setting thread_type. Perhaps I could configure it in DecoderOptions, but this isn't intuitive. Additionally, I've tried the following code to detect supported thread_type, but it's unreliable. FF_THREAD_FRAME causes avcodec_open2 to crash without a catchable error, so I always use FF_THREAD_SLICE.
bool supportsFrameThreading = (codec->capabilities & ffmpeg.AV_CODEC_CAP_FRAME_THREADS) != 0;
bool supportsSliceThreading = (codec->capabilities & ffmpeg.AV_CODEC_CAP_SLICE_THREADS) != 0;
using var file = MediaFile.Open(@"D:\example\movie.mp4", new MediaOptions() {
VideoPixelFormat = ImagePixelFormat.Rgba32,
DecoderThreads = 16,
});
Can I make this kind of setting?
I noticed
DecoderThreads, but this is ineffective because multithreading requires settingthread_type. Perhaps I could configure it inDecoderOptions, but this isn't intuitive. Additionally, I've tried the following code to detect supportedthread_type, but it's unreliable.FF_THREAD_FRAMEcausesavcodec_open2to crash without a catchable error, so I always useFF_THREAD_SLICE.