Avidemux Forum

Avidemux => Unix-Like (Linux/Bsd/...) => Topic started by: Blues on June 16, 2022, 05:17:48 PM

Title: Only two threads?
Post by: Blues on June 16, 2022, 05:17:48 PM
I'm using NVENC and noticed it runs on only one CPU thread. After switching to software decoding I get two threads, still not enough. This raises two questions.
1. Why can't I use Intel HW decoding and multiple NVENC processing threads?
2. Why processing is limited to two threads, even when set to 4 in Preferences. I have an Intel i7 with 8 threads.
Title: Re: Only two threads?
Post by: szlldm on June 16, 2022, 08:44:26 PM
Quote from: Blues on June 16, 2022, 05:17:48 PM1. Why can't I use Intel HW decoding and multiple NVENC processing threads?

NVENC is a hardware accelerated encoder, not related much to CPU and threads. In a hw decoder + hw encoder scenario the single thread used just transfer frames from the decoder to the encoder. This process couldnt be multithreaded.

Quote from: Blues on June 16, 2022, 05:17:48 PM2. Why processing is limited to two threads, even when set to 4 in Preferences. I have an Intel i7 with 8 threads.
Software decoder maximum thread count depends on the codec used in the source file.
X264 & X265 can utilize almost all available threads, usually older codecs (mpeg2,4) are limited in multithreading
Title: Re: Only two threads?
Post by: Blues on June 17, 2022, 06:06:23 PM
1. I understand the transfer is single threaded, but my question was why can't further processing be multithreaded?
2. I see there is a bottleneck, one thread of avidemux running at 100% in one thread, plus 4 threads of avidemux with low load. Using H.264 1920p test file as input Handbrake encodes at 350 FPS, Avidemux gets 150 FPS. With Handbrake I believe nVidia encoder is the limiting factor, with Avidemux it is something else.
Title: Re: Only two threads?
Post by: eumagga0x2a on June 17, 2022, 07:20:10 PM
Quote from: Blues on June 17, 2022, 06:06:23 PM1. I understand the transfer is single threaded, but my question was why can't further processing be multithreaded?

If you use VA-API for video decoding, this can be detrimental when you process video vs just display it. The reason is a very slow transfer speed from hw surfaces to normal memory with VA-API. You might speed up the process if you disable hw decoding and instead enable multi-threaded software decoding (the setting in Preferences controls only libavcodec software decoder).

Multi-threaded hw decoding is currently not possible due to the way hw surfaces are allocated and managed.

Regarding NVENC, we don't speak to the driver ourselves, NVENC encoder plugins in Avidemux are just wrappers around *_nvenc encoders from libavcodec which don't support multi-threading.

Regarding x264, the default setting is to let the library calculate the optimal number of threads.