Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
28th December 2023, 14:56 | #1 | Link |
Registered User
Join Date: Dec 2022
Posts: 64
|
Limit the number of cores for encoding
I want to limit the number of cores. In total I have 4 cores and 8 threads. I only need 6 threads for video encoding in the background (this is 80% of the computer’s power), and at this time I use the remaining threads for other work. I can change the number of processors in the Task Manager, but I have to do this every time. I wanted to do this automatically.
Now I'm trying this: Code:
start /affinity 3F C:\ffmpeg.exe In general, the FFMPEG script looks like this: Code:
FOR %%F IN (*.mp4) DO ( echo LSMASHVideoSource("%%~dpnxF"^) > "%%~dpnxF.avs" echo SetFilterMTMode("DEFAULT_MT_MODE", 2^) >> "%%~dpnxF.avs" echo LoadPlugin("D:\ResampleMT.dll"^) Spline36ResizeMT(720, 1280, prefetch=4^) >> "%%~dpnxF.avs" echo KNLMeansCL(D=1, A=1, h=1.5, device_type="auto"^) >> "%%~dpnxF.avs" echo DetailSharpen(str=0.3, pow=8, z=6, ldmp=0, mode=1, med=false^) >> "%%~dpnxF.avs" echo Prefetch(6^) >> "%%~dpnxF.avs" C:\ffmpeg.exe -benchmark -i "%%~dpnxF.avs" -i "%%~dpnxF" -map 0:v:0 -map 1:a:0 -c:v libx264 -qp 26 -preset medium -g 30 -keyint_min 5 -c:a copy "%%~dpnF_new.mp4" del "%%~dpnxF.avs" ) pause |
28th December 2023, 15:23 | #3 | Link |
Registered User
Join Date: Dec 2022
Posts: 64
|
Can I use both -x264-params and standard libx264 options in a script?
It seems to me that the encoding process loads the processor and video card 100% not only with the work of the libx encoder, but also with the work of the Avisynth filters. |
28th December 2023, 19:02 | #5 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,992
|
I used to use this years ago [EDIT: Maybe before I joined D9 (2010)], and recently downloaded again (maybe same version, probably not upated for some time).
Allows to always use some Priority, or some Affinity when executing an app. https://prio.en.softonic.com/ EDIT: Causes Task manager to set defaults for a particular executable, eg x264.exe or ffmpeg.exe. (So if you set some affinity on x264, and you execute MeGUI which uses/calls x264, then it will use that affinity for the MeGUI or any other, x264) EDIT: Free for personal use, I believe that it still works for current OS's, but not tried it myself, yet. EDIT: Task Manager, CTRL / SHIFT / ESC, shortcut.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 28th December 2023 at 19:46. |
29th December 2023, 12:09 | #6 | Link |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 103
|
This is the standard command structure I use for background encoding on a PC which can be 24/7 on (it is windows 10).
Code:
start /b /low /wait cmd /c "ffmpeg -y -hide_banner -nostdin -bitexact -i "%%i" -map 0 -vf "removegrain=1,scale=1280:720:flags=bicublin:param0=0.125:param1=0.4375" -sws_flags accurate_rnd -c:v libx264 -level 40 -preset veryslow -crf 18 -tune animation -psy-rd 0.55 -aq-mode 3 -threads 1 -c:a libfdk_aac -rmvol 0.9375 -vbr 4 -c:s copy -disposition +0 -bitexact "%tmdir%\t1_%pref%%%~ni%suff%.mkv" 2>&1 | tee "%lgdir%\full-log_%%~ni.txt"" - Note the -threads option which is sent to libx264. Probably ffmpeg uses also other threads e.g. audio encoding, filters, avisynth etc... - The cmd /c part can be omitted if the command is somewhat simple. cmd has a very strange quotation handling (see cmd /?) and here it is needed to redirect output to tee.exe, since I need both file and screen outputs. Perhaps you can also do it with start only but I was not able to do it. - You can tune the start parameters according to your needs. EDIT: Probably you do not see ffmpeg log since ffmpeg outputs to stderr instead of stdout, and start grabs only stdout. To redirect stderr to stdout use "2>&1" Last edited by hellgauss; 29th December 2023 at 13:34. Reason: Post scriptum |
Thread Tools | Search this Thread |
Display Modes | |
|
|