Log in

View Full Version : Another Megui x264 error code crash thread


hunter_aran
12th December 2011, 21:43
I am still rather new at using Avisynth/Megui and wanted to know if anyone has any ideas why it's crashing for me. The crash happens as x264 increases it's RAM usage sharply and shortly before it maxes out the 2GB that my virtual machine uses, it crashes, usually with error code -1073741819. In this case it's not intermittent and happens every time, usually within 5 minutes of the first pass. Funny thing is that several other scripts with the same source and very minor differences run so it's something I wrote in that's causes the memory leak.

Here's the problem script:

SetMemorymax(512)
SetMTMode(mode=2, threads=0)
Import("C:\Program Files\AviSynth 2.5\plugins\aaa.avs")
DGDecode_MPEG2Source("\\psf\home\desktop\D2V Project Files\Spongebob S2 D2V\Spongebob_2_Your_Shoes_Untied.d2v")
global MeGUI_darx = 120
global MeGUI_dary = 91
AnimeIVTC(mode=1)
srestore(omode=4)
crop(4, 0, -4, 0)
DeHalo_alpha(rx=1.5, ry=1.5, darkstr=1.5, brightstr=1.5, lowsens=80, highsens=20)
vmtoon(sharpen=false, thinning=0, strength=50)
aaa()

Here's the one that works fine:

SetMemorymax(512)
SetMTMode(mode=2, threads=0)
Import("C:\Program Files\AviSynth 2.5\plugins\aaa.avs")
DGDecode_MPEG2Source("\\psf\home\desktop\D2V Project Files\Spongebob S2 D2V\Spongebob_2_Your_Shoes_Untied.d2v")
global MeGUI_darx = 4
global MeGUI_dary = 3
AnimeIVTC(mode=1)
srestore(omode=4)
crop(4, 0, -4, -2)
DeHalo_alpha(rx=1.5, ry=1.5, darkstr=1.5, brightstr=1.5, lowsens=80, highsens=20)
vmtoon(sharpen=false, thinning=0, strength=50)
aaa()


The only thing I changed is adding the crop on the bottom of
-2 and adjusting the encoded AR to what Megui's "clever anamorphic" to 4:3. That part is a little strange to me given that the "clever anamorphic" is saying 4:3 when I was under the impression that any cropping will change the AR to preserve the proportion.

Any ideas why the cropping/AR change might be causing this memory leak in x264? Thanks a lot!

Edit: Actually I tested the second script all the way through and it crashed too. If I change the crop, AR, AND use the default for srestore (not omode=4) it works fine so maybe that's the culprit. But srestore(omode=4) after AnimeIVTC(mode=1) was the only way I've found to get rid of the blend telecined footage. Mode=2 on AnimeIVTC did not get rid of them and default srestore does another round of decimation which I do not need. I'll try using srestore by itself and see what happens I guess...

Edit2: Well it's still not working so I guess at this point it's a problem with srestore. AnimeIVTC does use srestore but I only got that warning about not calling srestore twice when I use it in conjuction with AnimeIVTC(mode=2), not mode=1. I also tried running srestore under SetMtMode=5 but no cigar. I'm kinda at a loss of what to do other than toss out srestore all together but it's a shame considering it worked so well when previewed in VDub.

Edit3: Well the scripts with srestore and the 4,0,-4,0 cropping started to work after starting them enough times (?) so it was not srestore after all, howevere the result, when seen in real time, was too noticeably choppy. So I messed around with it more and figured out that if I put the cropping at the end of the script, the memory leaks go away! I read that cropping right after IVTC, you will use less time encoding because you cut off all those black pixels out before further filtering but I guess it screws it all up somehow. Anyway, at least if someone has some similar problem, it might be just a case of changing the order of your filters.

chainring
16th December 2011, 22:18
First, what processor are you using?

Second, on your first SetMTMode call, before the source, it should be (5,x), where "x" = cpu threads. Note: generally not beneficial to go over 3 threads, even with a quad core CPU.

I'm not sure if it matters, but why is the aspect ratio signaling info not the first in your script?

This:
SetMemorymax(512)
SetMTMode(mode=2, threads=0)
Import("C:\Program Files\AviSynth 2.5\plugins\aaa.avs")
DGDecode_MPEG2Source("\\psf\home\desktop\D2V Project Files\Spongebob S2 D2V\Spongebob_2_Your_Shoes_Untied.d2v")
global MeGUI_darx = 4
global MeGUI_dary = 3
AnimeIVTC(mode=1)
srestore(omode=4)
crop(4, 0, -4, -2)
DeHalo_alpha(rx=1.5, ry=1.5, darkstr=1.5, brightstr=1.5, lowsens=80, highsens=20)
vmtoon(sharpen=false, thinning=0, strength=50)
aaa()

To this:

global MeGUI_darx = 4
global MeGUI_dary = 3
SetMemorymax(512)
SetMTMode(5,3) # Quad core CPU
Import("C:\Program Files\AviSynth 2.5\plugins\aaa.avs")
DGDecode_MPEG2Source("\\psf\home\desktop\D2V Project Files\Spongebob S2 D2V\Spongebob_2_Your_Shoes_Untied.d2v")
SetMTMode(2)
AnimeIVTC(mode=1)
srestore(omode=4)
crop(4, 0, -4, -2)
DeHalo_alpha(rx=1.5, ry=1.5, darkstr=1.5, brightstr=1.5, lowsens=80, highsens=20)
vmtoon(sharpen=false, thinning=0, strength=50)
aaa()

Others will have to chime in for the correct placement of the second SetMTMode and what mode(s) you may have to use.

hunter_aran
17th December 2011, 08:01
Hi! First thanks for the response. I have the Sandy Bridge Core i7 (Macbook Pro) and I'm using Avisynth 2.5.8 if that makes a difference. I thought putting threads=0 makes it default to the amount of available threads possible. It registers 99% CPU use in Windows however it's only really about half used since I limited Parallels to 4 threads. I didn't know SetMTMode should be set to mode 5 before the source. There was no problem with DGDecode and mode 2 in the MT documentation so I thought using it was fine. Also it just made sense for me to set the AR after the source was loaded. I still have memory leak crash every 6-8 passes though but then when I try to run that bad job again, it works fine the second time. I pulled out my RAM and reset it in case there might have been a problem but it made no difference.

hunter_aran
17th February 2012, 19:30
Ok I figured out what it probably is. I am not an expert so this is jus a guess but I thought it helpful to post considering maybe others might have a similar situation going on. There are problems with virtual machines such as VMware and Parallels allocating memory. Every time my computer goes to reserve battery, it freezes on restart and gives a bad RAM three-beep error, which is a fairly serious hardware error on Macs. There is NOTHING wrong with the RAM and I even had it replaced to make sure and the logic board on my computer was replaced under warranty for another issue and the problems persisted. So I am under the impression that since I have 8GB RAM and only 2GB of that can be used by Windows XP and Parallels, that Parallels is just stupid at times and trys to access memory that is not available. That's why I get the "bad access" or "trying to write to protected memory" or "runtime error" messages. Until there is a fix made for Parallels, it seems that I just have to deal with it crashing every once in a while. It is pretty annoying considering that I might leave the computer encoding all day, come home and the encoding stopped after one hour. I wish there was a way to automate it so that when an error happens, megui just says "ok" in the window and resumes encoding the next job.