Log in

View Full Version : AviSynth script cause of MeGUI/AVStoDVD crashes?


ZenoArrow
27th June 2011, 22:32
Hi all,

New to AviSynth and these forums, trying to understand some behaviour I'm seeing on my computer.

I've written an AviSynth script that takes a raw mpg DVD rip as input and performs a bunch of filters, mostly to convert from NTSC to PAL and to clean up/hide some audio artifacts. However, when I try using this script in MeGUI and AVStoDVD (and possibly VirtualDub too, I can't remember), the applications seem unstable. In the case of MeGUI, it was working before when my script was simpler, so I'm thinking I've done something wrong with the script (but it could be just my bad luck after updating MeGUI).

This is my first AviSynth script, and no doubt I'm made some mistakes along the way, please take a look and let me know what you think (changed the name of the audio/video source, but otherwise the script is unchanged):

-------------------------------------------------------
#Get video source
Video = DirectShowSource("a.mpg",audio=false)
#Get audio source
Audio = DirectShowSource("a.mpg",video=false)

#Perform EQ on audio and normalize
Audio = SuperEq(Audio,"C:\Program Files\AviSynth 2.5\plugins\rollofftopendandbot.feq")
Audio = Normalize(Audio,0.5)

#Change frame size for NTSC to PAL conversion
Video = Lanczos4Resize(Video,756,504)
Video = Crop(Video,16,0,-16,0)
Video = AddBorders(Video,0,36,0,36)

#Mux video and audio
AudioDub(Video, Audio)

#Set variables needed for framerate change
super=MSuper(pel=1)
backward_vec = MAnalyse(super,isb=true)
forward_vec = MAnalyse(super,isb=false)

#Perform framerate change
MFlowFps(super,backward_vec,forward_vec,num=25,den=1,ml=100)

#Deinterlace video
SmoothDeinterlace(doublerate=true)

#Sharpen image
LSFmod(defaults="old",ss_x=1.0,ss_y=1.0,secure=true,strength=40)
-----------------------------------------------------------

Any advice is greatly appreciated. Thank you in advance.

Tommy B.
27th June 2011, 22:46
Try removing the MVTools part and see if it gets stable.

Are you using the MT-plugin?

Mounir
28th June 2011, 00:03
LSFmod crash staxrip 100% sure of that so it's probably the same with megui

Gavino
28th June 2011, 01:15
Nothing to do with your crash problem, but you should be deinterlacing before resizing.

Also, your final width is 724 when it should be 720 for PAL SD.

And it's better to use MPEG2Source than DirectShowSource for mpg sources.

ZenoArrow
28th June 2011, 10:33
Try removing the MVTools part and see if it gets stable.

Are you using the MT-plugin?

Thanks for your reply Tommy B. I could try removing the MVTools part, but I am using it to alter the frame rate from 29fps (29.97?) to 25fps. This is an essential function in the script, so I'd need an alternative. I do not want to just drop frames, I like the 'frame morph' (sorry, don't know official name) method of altering the frame rate. Can you suggest another plugin that would do the same job to an equal/better level?

As for MT-plugin, all the plugins I'm using can be seen in the script, I'm trying to keep the AviSynth script as complete as possible so that it gives standard results no matter which program I use (which is why I'm normalising audio in the script rather than doing so through audio encoding options in MeGUI, for example). What is the MT-plugin, and why should I use it? Thank you in advance for your advice, I'm a noob, I'm sure there are good reasons for using it.

LSFmod crash staxrip 100% sure of that so it's probably the same with megui

Thank you for the tip Mounir. Is there another plugin for sharpening an image that you could recommend instead of LSFmod?

Nothing to do with your crash problem, but you should be deinterlacing before resizing.

Also, your final width is 724 when it should be 720 for PAL SD.

And it's better to use MPEG2Source than DirectShowSource for mpg sources.

Have no problem moving the deinterlace command (will put it just after the command to normalise audio), thank you for the tip Gavino.

I am aware that the width isn't precisely what it should be, but that's because I chose to make a compromise. When changing the video frame size between NTSC and PAL sizes, I could either add borders to get the right size or zoom the image to get the right size. I didn't want big borders, and I didn't want to lose too much of the image, so I made a compromise; I decided to zoom in a little and have smaller borders. 724 was the closest I could get using this method. If I could change the Crop command to Video = Crop(Video,18,0,-18,0) I would, but I remember an error appearing last time I tried this, something to do with pixels no longer being square IIRC.

I am happy to use MPEG2Source, but how would you suggest that I split out the audio and video into separate variables? From looking at the MPEG2Source documentation, I haven't seen an option to do this. I would just use AC3Source for audio, but the audio is embedded in the mpg file. Can AC3Source extract audio from an mpg file?

Gavino
28th June 2011, 10:54
I am happy to use MPEG2Source, but how would you suggest that I split out the audio and video into separate variables? From looking at the MPEG2Source documentation, I haven't seen an option to do this. I would just use AC3Source for audio, but the audio is embedded in the mpg file. Can AC3Source extract audio from an mpg file?
DGIndex (which is a necessary step before MPEG2Source) will demux the audio from the mpg and you can then use (Nic)Ac3Source. See the DGIndex documentation.

Tommy B.
28th June 2011, 21:23
It might be as well that a certain combination of filters in your filter-chain might lead to crashes.

If you can find out which of the filters is crashing your encoder, you might split up the script into parts and create intermediate files.

In my experience, MVTools is quite unstable when combined with certain scripts. I am using MDegrain2+FFT3DFILTER+LIMITEDSHARPENFASTER quite happily at the moment without crashes. LSFMod on the other hand made my encoders crash often when combined with MDegrain2... this was usually unpredictable and occured randomly between 5.000 and 50.000 encoded frames.

ZenoArrow
1st July 2011, 00:54
DGIndex (which is a necessary step before MPEG2Source) will demux the audio from the mpg and you can then use (Nic)Ac3Source. See the DGIndex documentation.

Thank you Gavino. I believe I've got the basics of DGIndex now, and my script currently uses MPEG2Source and NicAC3Source for setting video and audio source respectively. This is the most up to date version of the script (unchanged):

#Get video source
Video = MPEG2Source("How To Bring It.d2v")
#Get audio source
Audio = NicAC3Source("How To Bring It T80 2_0ch 192Kbps DELAY 0ms.ac3")

#Perform EQ on audio and normalize
Audio = SuperEq(Audio,"C:\Program Files\AviSynth 2.5\plugins\rollofftopendandbot.feq")
Audio = Normalize(Audio,0.5)

#Deinterlace video
Video = SmoothDeinterlace(doublerate=true)

#Change frame size for NTSC to PAL conversion
Video = Lanczos4Resize(Video,756,504)
Video = Crop(Video,16,0,-16,0)
Video = AddBorders(Video,0,36,0,36)

#Mux video and audio
AudioDub(Video, Audio)

#Set variables needed for framerate change
super=MSuper(pel=1)
backward_vec = MAnalyse(super,isb=true)
forward_vec = MAnalyse(super,isb=false)

#Perform framerate change
MFlowFps(super,backward_vec,forward_vec,num=25,den=1,ml=100)

#Sharpen image
LSFmod(defaults="old",ss_x=1.0,ss_y=1.0,secure=true,strength=40)

There are two issues I'm encountering now. I moved the SmoothDeinterlace function as you suggested, but when I try playing the .avs in Windows Media Player I get an error telling me: 'Script error: Invalid arguments to function "SmoothDeinterlace"'. I think the issue could be that I'm trying to double the video frame rate before I have muxed the video and audio together. What do you think could be the problem?

The second issue is that I think I've overused variables. Script seems much slower than it was before I needed to set variables for Video and Audio (i.e. when I was using filters on a single file). Is there anything I can do to streamline my existing script, performance wise? It's tricky to tell whether the audio is in sync with the video at the moment, I want to avoid having to encode a video file just to check the sync is there.

Thank you again. Anyone with advice on these points?

It might be as well that a certain combination of filters in your filter-chain might lead to crashes.

If you can find out which of the filters is crashing your encoder, you might split up the script into parts and create intermediate files.

In my experience, MVTools is quite unstable when combined with certain scripts. I am using MDegrain2+FFT3DFILTER+LIMITEDSHARPENFASTER quite happily at the moment without crashes. LSFMod on the other hand made my encoders crash often when combined with MDegrain2... this was usually unpredictable and occured randomly between 5.000 and 50.000 encoded frames.

Tommy B, you are probably right that it's probably a certain combination of filters is causing crashes, and I know the first thing to do when troubleshooting is to try to isolate the cause through experimentation.

I'm still new to AviSynth so haven't got enough knowledge to make truly informed decisions about the merits of various plugins. Will try LimitedSharpenFaster to see if that improves stability for me, but will need to fix more essential functions first (see my response to Gavino).

Gavino
1st July 2011, 01:22
There are two issues I'm encountering now. I moved the SmoothDeinterlace function as you suggested, but when I try playing the .avs in Windows Media Player I get an error telling me: 'Script error: Invalid arguments to function "SmoothDeinterlace"'. I think the issue could be that I'm trying to double the video frame rate before I have muxed the video and audio together. What do you think could be the problem?
You are missing the input clip argument:
Video = SmoothDeinterlace(Video, doublerate=true)
Previously (in its old position), it was using 'last' as the implicit input. Now here, no 'last' has yet been set up since all the filter results are assigned explicitly to other variables.

The second issue is that I think I've overused variables. Script seems much slower than it was before I needed to set variables for Video and Audio (i.e. when I was using filters on a single file).
Using variables doesn't affect speed.

ZenoArrow
1st July 2011, 10:00
You are missing the input clip argument:
Video = SmoothDeinterlace(Video, doublerate=true)
Previously (in its old position), it was using 'last' as the implicit input. Now here, no 'last' has yet been set up since all the filter results are assigned explicitly to other variables.

Ah, right you are. The clip variable isn't mentioned in the SmoothDeinterlace documentation, but it does make sense that it is needed.


Using variables doesn't affect speed.

Good to hear, guess decline in speed is from using a more filter-heavy script than before, I guess I'll just have to encode to a fixed file to check audio sync.

The newest version of my script seems to work fine with MeGUI now (no crashes as yet), will leave it as it is, and if issues still arise will try replacing LSFmod with LimitedSharpenFaster. Thank you to all that have helped me out (especially Gavino), you are all a credit to this community. :)