Log in

View Full Version : Avisynth error while encoding with HCEnc


Alex-Kid
3rd August 2009, 00:22
Hi, I'm making a DVD-9 with sports footage and got some problems when encoding to MPEG-2 with HCEnc. This is the script used:
setmemorymax(1024)
import("Trans.avsi")

a=avisource("01.avi")
b=avisource("02.avi")
c=avisource("03.avi")
d=avisource("04.avi")
e=avisource("05.avi")
f=avisource("06.avi")
g=avisource("07.avi")
h=avisource("08.avi")
i=avisource("09.avi")
j=avisource("10.avi")
k=avisource("11.avi")
l=avisource("12.avi")
m=avisource("13.avi")
n=avisource("14.avi")
o=avisource("15.avi")
p=avisource("16.avi")
q=avisource("17.avi")
r=avisource("18.avi")
s=avisource("19.avi")
t=avisource("20.avi")
u=avisource("21.avi")
v=avisource("22.avi")
w=avisource("23.avi")
x=avisource("24.avi")
y=avisource("grupos.avi")

Trans(a.fadein(15),b.trim(0,b.framecount-31))\
+trans(b.trim(b.framecount-30,0),c.trim(0,c.framecount-31))\
+trans(c.trim(c.framecount-30,0),d.trim(0,d.framecount-31))\
+trans(d.trim(d.framecount-30,0),e.trim(0,e.framecount-31))\
+trans(e.trim(e.framecount-30,0),f.trim(0,f.framecount-31))\
+trans(f.trim(f.framecount-30,0),g.trim(0,g.framecount-31))\
+trans(g.trim(g.framecount-30,0),h.trim(0,h.framecount-31))\
+trans(h.trim(h.framecount-30,0),i.trim(0,i.framecount-31))\
+trans(i.trim(i.framecount-30,0),j.trim(0,j.framecount-31))\
+trans(j.trim(j.framecount-30,0),k.trim(0,k.framecount-31))\
+trans(k.trim(k.framecount-30,0),l.trim(0,l.framecount-31))\
+trans(l.trim(l.framecount-30,0),m.trim(0,m.framecount-31))\
+trans(m.trim(m.framecount-30,0),n.trim(0,n.framecount-31))\
+trans(n.trim(n.framecount-30,0),o.trim(0,o.framecount-31))\
+trans(o.trim(o.framecount-30,0),p.trim(0,p.framecount-31))\
+trans(p.trim(p.framecount-30,0),q.trim(0,q.framecount-31))\
+trans(q.trim(q.framecount-30,0),r.trim(0,r.framecount-31))\
+trans(r.trim(r.framecount-30,0),s.trim(0,s.framecount-31))\
+trans(s.trim(s.framecount-30,0),t.trim(0,t.framecount-31))\
+trans(t.trim(t.framecount-30,0),u.trim(0,u.framecount-31))\
+trans(u.trim(u.framecount-30,0),v.trim(0,v.framecount-31))\
+trans(v.trim(v.framecount-30,0),w.trim(0,w.framecount-31))\
+trans(w.trim(w.framecount-30,0),x.trim(0,x.framecount-31))\
+trans(x.trim(x.framecount-30,0),y.fadeout(25))
reinterpolate411()
converttoyv12()

with AVI-DV files decoded through ffdshow YUY2 codec and the following transition script (it uses TransAll plugin):
Function Trans(clip src1, clip src2) {

trof=ImmaRead("F:\highlights\trans.png")
cua=FrameCount(src1)

TransWipe(src1,src2,25,"left")
animate(cua-30,cua+5,"overlay", trof,720,0,showalpha(trof),1.0,"blend", trof,-300,0,showalpha(trof),1.0,"blend")
}
The video file generated by the script has 478838 frames and it's well loaded in VirtualDub and HCEnc 0.23. But when I encode to MPEG-2, the process stops with a "pass 1: avisynth error at frame 226840" message, and task manager shows HCenc_023.exe process with 1.5 GB of memory use. My computer has a Core2Quad processor with 3 GB DDR2 RAM).

Please somebody help me solve this issue.

Saludos

By ALEX-KID

Gavino
3rd August 2009, 09:20
To reduce memory usage, you can move the call of ImmaRead
trof=ImmaRead("F:\highlights\trans.png")
into the body of the script (so that it's only called once), and make trof a parameter of function Trans:
Function Trans(clip src1, clip src2, clip trof)
changing the calls accordingly.

Alex-Kid
3rd August 2009, 22:36
Ah, nice tip. I'm not good saving memory usage when doing scripts. I'll try this when I get home.

Could it be more "efficient" to call TransWipe from the script itself too?

Gavino
4th August 2009, 00:08
Could it be more "efficient" to call TransWipe from the script itself too?
No, that shouldn't make any difference.
The point is that ImmaRead was being called many times when it is always using the same image and so only needs to be called once. In the case of TransWipe, you still need to call it once per transition, so you can't get rid of any calls - whether you call it inside or outside the function doesn't matter.

If this still doesn't work, try simplifying your script in different ways to find out what is to blame. Things to try:
- replace TransWipe by simple Dissolve;
- replace animated overlay by a static one;
- remove overlay altogether.

Alex-Kid
4th August 2009, 15:36
OK, thanks for your advice.

This time the new script was fully processed by HCEnc, but the output looks corrupt at minute 21, and the filesize is about 10.7 GB. I think it's still related to memory usage (when processing it reached about 1.4 GB but didn't stopped) so i'll keep trying.

Saludos

By ALEX-KID

IanB
4th August 2009, 16:39
Lose the setmemorymax(1024)!

This controls the size of the video frame cache it does not control the memory usage for other purposes. You only have 2 gigabytes of address space for a 32 bit process, allocating 50% to the frame cache is not very smart. For linear scripts with no temporal component a big cache serves no purpose.

Also animating Overlay will burn memory like there is no tomorrow. Look into using the conditional variables that can control Overlays behaviour as an alternative.

Alex-Kid
4th August 2009, 22:57
I always refused to learn the usage of conditional variables, but this time I think I have no choice. And I didn't know SetMemoryMax just got to do with video frame cache. There's always something new you can learn every day.

Thank you IanB

Saludos

By ALEX-KID

Gavino
4th August 2009, 23:20
I always refused to learn the usage of conditional variables, but this time I think I have no choice.
It's always good to learn new things, so I don't want to discourage you. :)
However, an alternative might be to pre-create the animated overlay as an external RGB32 clip (with transparency) and use that instead of the static image in your Trans function.

Alex-Kid
5th August 2009, 23:13
Before learning conditional scripting (still refusing it ;)) I modified the script removing call of Immaread (done it before) and split overlay calls to smaller intervals (hoping to reduce enough memory usage), splicing them with the "middle" of the video until next overlay call. I loaded the script successfully into HCEnc, but I haven't had the time to encode and to know how it works. I hope doing this at night.

By the way, should memory usage be reduced by doing this?

Saludos

By ALEX-KID

---------------------EDIT----------------------------

I reply myself: it is reduced, and finally got my video done. This is the last script:


import("Trans.avsi")

a=avisource("01.avi")
b=avisource("02.avi")
c=avisource("03.avi")
d=avisource("04.avi")
e=avisource("05.avi")
f=avisource("06.avi")
g=avisource("07.avi")
h=avisource("08.avi")
i=avisource("09.avi")
j=avisource("10.avi")
k=avisource("11.avi")
l=avisource("12.avi")
m=avisource("13.avi")
n=avisource("14.avi")
o=avisource("15.avi")
p=avisource("16.avi")
q=avisource("17.avi")
r=avisource("18.avi")
s=avisource("19.avi")
t=avisource("20.avi")
u=avisource("21.avi")
v=avisource("22.avi")
w=avisource("23.avi")
x=avisource("24.avi")
y=avisource("grupos.avi")

a.trim(0,a.framecount-31).fadein(15)+trans(a.trim(a.framecount-30,0),b.trim(0,30))\
+b.trim(31,b.framecount-31)+trans(b.trim(b.framecount-30,0),c.trim(0,30))\
+c.trim(31,c.framecount-31)+trans(c.trim(c.framecount-30,0),d.trim(0,30))\
+d.trim(31,d.framecount-31)+trans(d.trim(d.framecount-30,0),e.trim(0,30))\
+e.trim(31,e.framecount-31)+trans(e.trim(e.framecount-30,0),f.trim(0,30))\
+f.trim(31,f.framecount-31)+trans(f.trim(f.framecount-30,0),g.trim(0,30))\
+g.trim(31,g.framecount-31)+trans(g.trim(g.framecount-30,0),h.trim(0,30))\
+h.trim(31,h.framecount-31)+trans(h.trim(h.framecount-30,0),i.trim(0,30))\
+i.trim(31,i.framecount-31)+trans(i.trim(i.framecount-30,0),j.trim(0,30))\
+j.trim(31,j.framecount-31)+trans(j.trim(j.framecount-30,0),k.trim(0,30))\
+k.trim(31,k.framecount-31)+trans(k.trim(k.framecount-30,0),l.trim(0,30))\
+l.trim(31,l.framecount-31)+trans(l.trim(l.framecount-30,0),m.trim(0,30))\
+m.trim(31,m.framecount-31)+trans(m.trim(m.framecount-30,0),n.trim(0,30))\
+n.trim(31,n.framecount-31)+trans(n.trim(n.framecount-30,0),o.trim(0,30))\
+o.trim(31,o.framecount-31)+trans(o.trim(o.framecount-30,0),p.trim(0,30))\
+p.trim(31,p.framecount-31)+trans(p.trim(p.framecount-30,0),q.trim(0,30))\
+q.trim(31,q.framecount-31)+trans(q.trim(q.framecount-30,0),r.trim(0,30))\
+r.trim(31,r.framecount-31)+trans(r.trim(r.framecount-30,0),s.trim(0,30))\
+s.trim(31,s.framecount-31)+trans(s.trim(s.framecount-30,0),t.trim(0,30))\
+t.trim(31,t.framecount-31)+trans(t.trim(t.framecount-30,0),u.trim(0,30))\
+u.trim(31,u.framecount-31)+trans(u.trim(u.framecount-30,0),v.trim(0,30))\
+v.trim(31,v.framecount-31)+trans(v.trim(v.framecount-30,0),w.trim(0,30))\
+w.trim(31,w.framecount-31)+trans(w.trim(w.framecount-30,0),x.trim(0,30))\
+x.trim(31,x.framecount-31)+trans(x.trim(x.framecount-30,0),y.trim(0,30))\
+y.trim(31,0).fadeout(25)
reinterpolate411()
converttoyv12()

Anyway I'll learn how to use conditional variables :).

Saludos to everyone

By ALEX-KID