fix exceeding max allowed thread count, thread count <= available memory / 2

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-11-19 08:19:08 +08:00
parent c223d6a87d
commit 9847fc5c77
4 changed files with 34 additions and 14 deletions

View File

@@ -63,7 +63,7 @@ impl EncoderApi for HwEncoder {
gop,
quality: DEFAULT_HW_QUALITY,
rc: DEFAULT_RC,
thread_count: codec_thread_num() as _, // ffmpeg's thread_count is used for cpu
thread_count: codec_thread_num(16) as _, // ffmpeg's thread_count is used for cpu
};
let format = match Encoder::format_from_name(config.name.clone()) {
Ok(format) => format,
@@ -235,7 +235,7 @@ impl HwDecoder {
let ctx = DecodeContext {
name: info.name.clone(),
device_type: info.hwdevice.clone(),
thread_count: codec_thread_num() as _,
thread_count: codec_thread_num(16) as _,
};
match Decoder::new(ctx) {
Ok(decoder) => Ok(HwDecoder { decoder, info }),