[FFmpeg-user] FFmpeg Thread Command - Performance, Quality & Encoding Size

Anand Veerappan anandzone at gmail.com
Fri Oct 11 08:51:18 EEST 2019


Hi

While encoding a video file using FFmpeg we have option to handle thread
parameter. I used Quad Core Processor and find below my observations.

*Case 1: Default thread usage*
By default if we didn't specify thread value FFmpeg internally adjusts
thread count usage based on the core architecture of the deployment machine.

Example:

ffmpeg -i football_1080p.mp4 -c:v libx264 -b:v 3M -bufsize 6M -maxrate
4.5M  -g 120 -tune psnr -report football_1080p_3M_threads_1_p.mp4

If I repeat this command n times for encoding always the encoded file size
is similar in all iterations.

*Case 2: Manually forced thread count usage*


* Example 1: Thread count 1*

ffmpeg -i football_1080p.mp4 -c:v libx264 -b:v 3M -bufsize 6M -maxrate 4.5M
-*threads 1* -g 120 -tune psnr -report football_1080p_3M_threads_1_p.mp4


*Example 2: Thread count 6*

ffmpeg -i football_1080p.mp4 -c:v libx264 -b:v 3M -bufsize 6M -maxrate 4.5M
-*threads 6* -g 120 -tune psnr -report football_1080p_3M_threads_1_p.mp4

 *Example 3: Thread count 9*

ffmpeg -i football_1080p.mp4 -c:v libx264 -b:v 3M -bufsize 6M -maxrate 4.5M
-*threads 9* -g 120 -tune psnr -report football_1080p_3M_threads_1_p.mp4

*Example 4: Thread count 20*

ffmpeg -i football_1080p.mp4 -c:v libx264 -b:v 3M -bufsize 6M -maxrate 4.5M
-*threads 20* -g 120 -tune psnr -report football_1080p_3M_threads_1_p.mp4

If I repeat this command 4 times for encoding the encoded file size differs
with few KB in all iterations.  Why is this difference ?

That implies that if I put the thread count at 0 on two different machine
architectures, I will again get two different output file sizes for the
same thread count (0, in this case) and same input file.

Also I am curious to know the below mentioned quires

1. What does the threads command do?
2. What does FFmpeg do if you don’t specify a threads value?
3. How does the threads settings impact performance?
4. How does the threads setting impact quality?

Please clarify.

Regards
Anand V


More information about the ffmpeg-user mailing list