Log in

View Full Version : CPU throttling using x264/MeGUI


abyss616
20th February 2018, 04:38
I have different scripts that I use to encode video in MeGUI - one is a very basic one for taking HD transport files from my DVR and encoding them to watch on my Kindle, and the second one is more intensive that I'm using to upscale 480i DVD video to 720p.

My issue is with the intensive script causing my CPU to throttle even though it seems to be using less resources than the basic one.

Script 1:
v=DSS2("E:\TonyGwynn.track_4113.mkv", fps=59.9401)
a=NicAC3Source("E:\TonyGwynn.track_4352.ac3")
AudioDub(v,a)
ColorMatrix()
UnDot()
SelectEven()
ConvertToYV12(matrix="Rec601", interlaced=false)


Script 2:
SetMemoryMax(1000)
SetMTMode(5, 8)
v=DSS2("E:\01-Miami.mkv", fps=29.970)
a=DirectShowSource("E:\01-Miami.mkv")
AudioDub(v,a)
ConvertToYV12(interlaced=true)
AssumeTFF()
SetMTMode(2)
QTGMC(Preset="Slower", SourceMatch=3, Lossless=2, EdiThreads=2)
Distributor()
Spline64Resize(1280,720)
LimitedSharpenFaster()


On script 1, I encode at 750 ABR. CPU usage is at ~95% and temps are in the low-mid 60s c. Encoding takes around 45 minutes per 44-minute show.

On script 2, I encode at 3500 2-pass. CPU usage is at ~65% and temps are in upper 50s/low 60s. The CPU throttles back about 15 minutes into the first pass. If I set MT mode to 5,14, the CPU usage will max out at ~99%, but the throttling takes place a lot sooner (around 5 minutes in).

Using QTGMC gets me good results, but I'm open to a different way if there's a faster/workable solution.

hello_hello
20th February 2018, 12:20
What's the CPU and how do you know it's throttling? My old Q9450 CPU happily runs at 90 degrees.

I've had a problem where encoding slows to a crawl, but it has nothing to do with the CPU throttling. If it happens, it's generally when combining QTGMC and LSFMod. Could this be the problem you're experiencing? https://forum.doom9.org/showthread.php?t=172744

If that's it, it's happened far less often for me since updating to QTGMC v3.357s (http://avisynth.nl/index.php/QTGMC), although that may be just coincidence. It still happens now and then.
The only fixes I've found, which don't always work, are to use Trim to crop off a small amount from the beginning of the script (meaning it has to be encoded in two sections and joined later), or by using MP_Pipeline (https://forum.doom9.org/showthread.php?t=163281) to run QTGMC and LSF in separate processes.

If none of the above applies, then I guess you need better cooling.

PS. If you're upscaling DVDs to 720p, you probably should convert the colours to rec.709 and set rec.709 as the color matrix in the x264 encoder configuration (under the misc tab). ColorMatrix(mode="Rec.601->Rec.709", clamp=0)

Mounir
20th February 2018, 12:29
* i don't think you have to use distributor (i never specify it and works ok with avisynth 2.6 mt)
* Do you really need the "slower" mode of qtgmc ? (it remove lots of grain,fine details...unless you're working with vhs-like contant)
* setmtmode 3 works fine with me for most filters, above that is overkill imo

abyss616
20th February 2018, 15:40
What's the CPU and how do you know it's throttling? My old Q9450 CPU happily runs at 90 degrees.

i7 2600 (Sandy Bridge).

I guess I don't know for certain it's throttling, I don't really know what's going on. All I know is everything runs fine for a certain amount of time, then everything cuts back and x264 goes from 90% CPU to a max of 30% and no higher.

I don't think it's cooling, because as I mentioned in my OP, the first script will run at 99% CPU for 45 minutes or more without any issues. It's only when QTGMC is introduced does it go wrong.

* i don't think you have to use distributor (i never specify it and works ok with avisynth 2.6 mt)
* Do you really need the "slower" mode of qtgmc ? (it remove lots of grain,fine details...unless you're working with vhs-like contant)
* setmtmode 3 works fine with me for most filters, above that is overkill imo

I think I took out Distributor as a test and everything slowed down considerably. I can try it again to see.

If I change 'slower' to 'slow', I get an error message, something about the QTGMC avsi. I'm away from my home computer so I don't know exactly what it is.

Are you talking about SetMTMode in the line above QTGMC or at the top of the script?

sneaker_ger
20th February 2018, 15:49
I guess I don't know for certain it's throttling, I don't really know what's going on. All I know is everything runs fine for a certain amount of time, then everything cuts back and x264 goes from 90% CPU to a max of 30% and no higher.
"Throttling" is usually associated with down-clocking. You can watch your CPU's clocks live with a software like CoreTemp (http://www.alcpu.com/CoreTemp/).

(So from this I take your CPU is most likely NOT throttling. But make sure to confirm using CoreTemp.)

I vaguely remember a similar thread. No idea if it's related as I'm too lazy to read it again.
https://forum.doom9.org/showthread.php?t=172744

hello_hello
20th February 2018, 23:28
I guess I don't know for certain it's throttling, I don't really know what's going on. All I know is everything runs fine for a certain amount of time, then everything cuts back and x264 goes from 90% CPU to a max of 30% and no higher.

It sounds like the problem I have now and then but it's never when just using QTGMC for me, it's when using QTGMC and LSFMod (LimitedSharpenFaster Mod) in the same script. Maybe QTGMC & LimitedSharpenFaster together can produce the same problem. Have a look at the thread I linked to.

It took me a while to realise what was happening as the encoding speed MeGUI's status displays is very slow to respond to changes in encoding speed. So it usually starts off normally and shows a gradual slowdown in speed, whereas the reality is, at some point encoding speed drops very quickly, if not instantly.

The last time it happened for me was only a week ago while encoding 6 episodes from a DVD. It was the first time in many months. The first two episodes encoded normally then the rest had the slowdown problem. When it started I even rebooted the PC but that didn't help.

My usual workaround is to make a copy of the script, add Trim so it's only encoding up to a scene change, ie Trim(0, 754), Then the second script encodes the rest. ie Trim(755, 0). MeGUI's AVS Cutter makes it easier to do as it has a preview. If you check --stitchable in the x264 encoder configuration you shouldn't have any problem appending the encoded video with MKVToolNix. You can still encode the audio in one go.
Often doing it that way will inexplicably fix the problem. If it doesn't, then after it slows again I split the encoded video at a scene change with MKVToolNix, and once again use Trim to encode the rest from the appropriate point. It's a pain in the bum, but fortunately it doesn't happen regularly. Or try MP_Pipeline.

You could also try switching between whichever version of Avisynth you have installed and MeGUI's portable version of Avisynth+. It didn't help last time I tried it, but that was a while ago and Avisynth+ has been updated a few times since then.

I'd seriously consider remuxing the MKV containing the DVD video as a TS file with TSmuxer and opening the TS file with MeGUI's file indexer and indexing it with DGIndex. I'm pretty sure DGIndex will extract the audio as it does from vob files, and you can load it into the audio section for encoding so you won't need to include audio in your script. Actually I think DGIndex should even open elementary video streams if you extract them from the MKV with gMKVExtractGUI or MKVCleaver and it's frame accurate. I'd trust it more that DSS2 or DirectShowSource. Not that it'll be likely to fix your problem, but you never know.

If I change 'slower' to 'slow', I get an error message, something about the QTGMC avsi. I'm away from my home computer so I don't know exactly what it is.

The only difference I can see between the two that's likely to cause an error is the slow preset requires TDeint, so if it's not loaded....
The slower preset is the QTGMC default though, and combined with SourceMatch & Lossless you shouldn't lose much detail.

abyss616
21st February 2018, 03:27
I tweaked my script a little for testing purposes. Changed it to SetMTMode(5,14) to max out the CPU and removed Distributor() and LimitedSharpenFaster().

My Core Temp readings (idle/load/scale back):
https://imgur.com/a/iVBM3 - won't embed for some reason.

Now it won't encode any longer than 2 minutes before the "throttling" happens.

EDIT: I have some non-interlaced 480 video that I'm upscaling to 720. I used the following NNEDI script with SetMTMode(5, 14):

nnedi3_rpow2(rfactor=2,cshift="spline36resize",fwidth=1280,fheight=720)
LimitedSharpenFaster()

My CPU is maxed out at ~99% and haven't had any issues, so it must be something with QTMGC.

abyss616
24th February 2018, 23:42
Two updates:

1) If I add SelectEven to my script, it completes the encode. Does this say anything to anyone?
2) I tried MP_Pipeline - I had to leave before it finished, so I'm not sure if I'm having the same problem, but while I was watching it, my frames per second was around 9 or so, much slower than the 30 I get without it.