View Full Version : Avisynth/ffmpeg cpu usage 30% or lower
Mawazi
16th February 2015, 20:13
I'm trying to figure out why avisynth/ffmpeg are not using more cpu time. According to task manager, I'm barely getting up to 30%. Memory is fine, about 20% in use. I'm using multithreaded avisynth, with what should be a fairly intense avisynth script that uses qtgmc:
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
SetMTMode(1,8)
video=MPEG2Source("C:\Users\Mark\Documents\DVDFab9\Video\BBCDVD3672\arkinspace4.d2v",idct=5,cpu=0,info=3)
audio=WAVsource("C:\Users\Mark\Documents\DVDFab9\Video\BBCDVD3672\arkinspace4.wav")
AudioDub(video, audio)
AssumeTFF()
# SetMTMode(2)
QTGMC(Preset="Placebo", SourceMatch=3, Lossless=2, EdiThreads=8)
Interframe(NewNum=60,NewDen=1,Cores=8)
SincResize(788, 576)
Crop(10,0,768,576)
I've tried a number of SetMTMode parameters without any further cpu usage. I've tried upping the cores/threads to 16, no more cpu usage.
I've used ffmpeg with just copy for vcodec and acodec, but get the same result as far as fps encoded, which makes it seem that ffmpeg is not at fault. Or is ffmpeg possibly not using all of the cores/threads?
Hardware wise I have an Intel Core i7 4790k, 16Gb Ram, and a Samsung 850 Pro SSD. This is a recent hw build.
It seems like there is a bottleneck somewhere that is obviously not cpu limited, but I just don't understand it.
Any ideas?
Reel.Deel
16th February 2015, 20:25
Well for starters you shouldn't really use MT mode 1 for source filters, QTGMC might perform better with mode 2, for Interframe take a look here (http://www.spirton.com/interframe/) for an example.
poisondeathray
16th February 2015, 20:40
avsmeter is a useful tool to determine where the bottleneck might be (likely it's the script)
if you cannot optmize script, you could run 2 more more parallel encodes
kuchikirukia
20th February 2015, 10:00
You don't need 64 edithreads.
Have you tried distributor()? I don't know if ffmpeg needs it. (I use megui)
Also, do you need Interframe? QTGMC will usually be putting out 60fps.
Witzig
20th February 2015, 16:13
Some food for thought. Probably not the answer you're looking for but still helpful:
"Important: Always remember to judge the result by looking at the speed improvement not the cpu utilization."
http://avisynth.nl/index.php/MT
Good luck
bxyhxyh
25th February 2015, 10:36
This happens to me on this script. When I check a script on AVSMeter CPU usage is 75% and speed is 4.5 fps. But when using ffmpeg it is 25-28% and 1.8 fps.
So I'm dividing my script into 2 parts and encoding same time without using MT.
#1st pass of the rip
SetMTMode(3,3)
DGDecode_mpeg2source("VTS_01_1.d2v", info=3)
SetMTMode(2)
qt=qtgmc(sourcematch=3,lossless=2).Selecteven()
qt2=qtgmc(preset="very slow",sharpness=0.2).Selecteven()
tf8=TFM(blockx=4,blocky=4,slow=2)
tf256=TFM(blockx=256,blocky=256,clip2=qt)
tf257=TFM(blockx=256,blocky=256,clip2=qt2)
TFM()
mask=FFImageSource("mask1.png").ConvertToYV12().loop(19000)
rf(tf256,1429,1434)
rf(tf8,2678,2775)
rf(qt2,9144,9147),
rf(tf8,9149,9149)
rf(tf257,13003,13084)
rf(qt,13041,13041)
rf(qt,13044,13044)
rf(qt,13046,13046)
rf(tf8,40430,42393)
rf(qt,40652,40652)
rf(qt,41790,41790)
rf(qt,41896,41896)
rf(qt,42030,42031)
rf(qt,42035,42036)
rf(tf256,42394,43069)
TDecimate(mode=1)
crop(4,2,-2,0)
nnedi3_rpow2(2,cshift="spline36resize")
crop(6,0,-6,0)
nonlinusm(z=3,pow=1.2,str=0.85,rad=0.6)
vmtoonmod(thinning=36,strength=16,xstren=128)
Groucho2004
25th February 2015, 10:54
This happens to me on this script. When I check a script on AVSMeter CPU usage is 75% and speed is 4.5 fps. But when using ffmpeg it is 25-28% and 1.8 fps.
FFMpeg probably doesn't automatically call "Distributor()" whereas AVSMeter does. Add "Distributor()" as the last statement to your script and the numbers should be similar.
Edit - How are you feeding the script to ffmpeg?
Tarutaru
26th February 2015, 10:18
This happens to me on this script. When I check a script on AVSMeter CPU usage is 75% and speed is 4.5 fps. But when using ffmpeg it is 25-28% and 1.8 fps.
So I'm dividing my script into 2 parts and encoding same time without using MT.
#1st pass of the rip
SetMTMode(3,3)
DGDecode_mpeg2source("VTS_01_1.d2v", info=3)
SetMTMode(2)
qt=qtgmc(sourcematch=3,lossless=2).Selecteven()
qt2=qtgmc(preset="very slow",sharpness=0.2).Selecteven()
tf8=TFM(blockx=4,blocky=4,slow=2)
tf256=TFM(blockx=256,blocky=256,clip2=qt)
tf257=TFM(blockx=256,blocky=256,clip2=qt2)
TFM()
mask=FFImageSource("mask1.png").ConvertToYV12().loop(19000)
rf(tf256,1429,1434)
rf(tf8,2678,2775)
rf(qt2,9144,9147),
rf(tf8,9149,9149)
rf(tf257,13003,13084)
rf(qt,13041,13041)
rf(qt,13044,13044)
rf(qt,13046,13046)
rf(tf8,40430,42393)
rf(qt,40652,40652)
rf(qt,41790,41790)
rf(qt,41896,41896)
rf(qt,42030,42031)
rf(qt,42035,42036)
rf(tf256,42394,43069)
TDecimate(mode=1)
crop(4,2,-2,0)
nnedi3_rpow2(2,cshift="spline36resize")
crop(6,0,-6,0)
nonlinusm(z=3,pow=1.2,str=0.85,rad=0.6)
vmtoonmod(thinning=36,strength=16,xstren=128)
Try to put distributor() at the end of the script.
I think it's depends on the filter you used,
In my case, it can use 100% of CPU when my script only calls QTGMC(), no distributor() is needed when piping avs to ffmpeg.
But it will only use 25% when i call autoadjust(), i need to add distributor() at the end to make it use 100% CPU and performance gain.
I'm runing avisynth and ffmpeg on Linux so this may not suite you.
bxyhxyh
26th February 2015, 17:15
Yeah, it worked. Thank you guys.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.