PDA

View Full Version : Script Problem Please Help


MarkTen
25th July 2005, 01:04
Hi all.

I'm new to avisynth and think the posibilities are awsome.
What I want to do is convert NTSC Mpegs to PAL Mpegs for output to DVD.

I was using VirtualDub MOD to import the the mpeg resize it from 480 to 576 with black bars and using the framerate option to inverse telecine 3:2 Pulldown removal saving out avi as huffyuv 2.1.1 compression. Then loading that back in to Vdub and changing frame rate to 25fps. Worked well on video. But audio was out tried changing length using stretchtime in soundforge 6.0. Nearly worked but just got worse sync as movie went on.

Then I found Poor man's video standards conversion script by Xesdeeni.
Didn't work at first because the smooth de-interlacer plugin wasn't compatible with avs 2.5. Found one that was.
Also the mpegdec plugin didn't work either. Found another one that worked as well. Seemed ready to go, then I got the error...

Avisynth open failure requires yuy2 input
Did some more searching found the function convertToYUY2()
Tried that it said invalid arguements. Put in my file name between the brackets. Still didn't work looked at the syntax
ConvertToYUY2(clip clip [....])

Can someone please explain how this works.
I even tried this simple script

Input = AVISource("I:\Knight3.avi")
ConvertToYUY2()

Still doesn't work. What am I doing wrong???
I want to use Xesdeeni's script because it says that it doesn't cause any audio desync problems.

Am I doing this all wrong or is there a better and easier way.

Please help if you can. i don't like troubling anyone. But I'm just about ready to give up on this whole thing!

Many Thanks in Advance

MarkTen

mg262
25th July 2005, 01:31
Here is the rough version: If you don't specify a clip to work on, AVISynth just uses the output of the last filter; now if you try this:

Input = AVISource("I:\Knight3.avi")
ConvertToYUY2()

then the first line doesn't output a clip; its stores that clip in the variable 'input' instead. so you would want to try this:

AVISource("I:\Knight3.avi")
ConvertToYUY2()

alternatively this would work just as well...

Input = AVISource("I:\Knight3.avi")
ConvertToYUY2(Input)

or even

Input = AVISource("I:\Knight3.avi")
Input.ConvertToYUY2()

which it is a shorthand for the second version. If you were to write something like this:

Input = AVISource("I:\Knight3.avi")
hzdfhzdfg = Input.ConvertToYUY2()

then you wouldn't be outputting a clip from the last command and you would get an error message.

HTH,
M.

Edit: If this isn't enough for you to sort out the problem, please post again including the full script you're trying out.

MarkTen
25th July 2005, 13:22
Thanks MG262 for your help.
Did what you sugested it doesn't throw up that error anymore.
But still throws up ConvertFPS needs YUY2 input.

Here's the script in full. Can't believe anyone would take the time to help me with such a complex problem. Many many thanks. If I can return the favour anytime please let me know.

MarkTen

######################################################################
#
# Poor man's video standards conversion (NTSC to PAL and PAL to NTSC)
#
# This script converts one INTERLACED video format to another
# INTERLACED video format.
#
# NOTE: This script is NOT meant to convert telecined films (that is,
# films that have been transferred to video). There are much better
# ways to convert that type of content (see the guides at
# www.doom9.net and www.vcdhelp.com). This script is best for
# INTERLACED content like HOME MOVIES shot with camcorders or live
# events. It is also good for mixed content (film + video).
#
#---------------------------------------------------------------------
#
# >>> Tools <<<
#
# This script is for use with AVISynth version 2.0.6 or above,
# available from http://www.avisynth.org.
#
# This script uses my AVISynth port of Gunnar Thalin's smooth
# deinterlacer, which is available at
# http://home.bip.net/gunnart/video/A...hDeinterlacer/.
# Place the plugin in an AVISynth plugin directory, so it can be
# accessed below.
#
#---------------------------------------------------------------------
#
# For comments/suggestions email me (Xesdeeni2001) at Yahoo dot com.
#
######################################################################
#
# >>> How It Works <<<
#
# This script works by first converting the input video from
# interlaced fields to progressive frames using an adaptive
# deinterlacer. Then the progressive frame rate is converted.
# Finally the progressive frames re-interlaced for output. Scaling
# is also performed where appropriate.
#
######################################################################
#
# >>> To Use <<<
#
# To use this script, first modify the lines below as specified.
# Then save the script with any name ending in .AVS.
#
#---------------------------------------------------------------------
#
# Set PluginPath equal to the path for your AVISynth plugins. Be sure
# to end the path with a backslash. Note that if you put the plugins
# in the system directory, you can leave this path completely empty.
# ex.:
# PluginPath = "C:\AVISynth\PlugIns\"
#

PluginPath = "C:\Program Files\AviSynth 2.5\plugins\"

#---------------------------------------------------------------------
#
# Set Input equal to the load directive for the input file. Also add
# any plugins necessary to load the video file. Note that if the clip
# contains audio, it is fed straight through without being modified,
# because the output video will have the same length as the input
# video.
# ex.:

#LoadPlugin(PluginPath + "MPEGDecoder.dll")
#Input = MPEGSource("I:\Knight1.mpg")

#

Input = AVISource("I:\Knight3.avi")
ConvertToYUY2(Input)

#---------------------------------------------------------------------
#
# Set InputTopFieldFirst to either true or false, depending on the
# format of your input file. DV files are normally bottom field
# first, so set this value to false. DVDs and most other sources are
# normally top field first, so set this value to true.
#

InputTopFieldFirst = true

#---------------------------------------------------------------------
#
# Set OutputFrameRate to the desired frame rate of your output video.
# For PAL, this is normally 25. For NTSC, this is normally 29.97.
# The input frame rate is derived directly from the input video.
#

OutputFrameRate = 25

#---------------------------------------------------------------------
#
# Set the OutputWidth and OutputHeight to the desired width and
# height of your output video. In most cases, the width of the
# output should match the width of the input. For PAL, the height
# is normally 576. For NTSC, the height is normally 480. The input
# width and height are derived from the input video.
#

OutputWidth = Input.width
OutputHeight = 576

#---------------------------------------------------------------------
#
# Set OutputTopFieldFirst to either true or false, depending on the
# desired format of your output file. See InputTopFieldFirst above.
#

OutputTopFieldFirst = true

#---------------------------------------------------------------------
#
# Set ConversionType to your desired type of frame rate conversion.
# The choices are:
# 0 - Replication/Decimation: Frames are repeated to increase the
# frame rate; frames are dropped to decrease the frame rate.
# This type of conversion is the fastest, but may show visible
# stuttering on motion when decreasing the frame rate (i.e.
# NTSC to PAL).
# 1 - Temporally Interpolate: Output frames are created by
# temporally interpolating between adjacent input frames. This
# type of conversion can show a "jutter" effect on motion, but
# is best when decreasing the framerate to ensure every input
# frame is at least partially shown in the output.
# 2 - Asynchronous: The conversion is done by showing the
# portions of the input frames that correspond to the time
# during which the output frame is visible. When decreasing
# the frame rate, this can cause some areas of some frames to
# never be seen, and can cause "broken" vertical edges on
# horizontal pans.
#

ConversionType = (OutputFrameRate <= Input.framerate) ? 1 : 0

#
######################################################################

LoadPlugin(PluginPath + "SmoothDeinterlacer.dll")

vpro = Input.SmoothDeinterlace(tff=InputTopFieldFirst, \
doublerate=true)
vinfps = Input.framerate < OutputFrameRate ? \
vpro.BilinearResize(OutputWidth, OutputHeight) : \
vpro
vfps = ConversionType == 2 ? \
vinfps.ConvertFPS(OutputFrameRate * 2, zone = 80) : \
ConversionType == 1 ? \
vinfps.ConvertFPS(OutputFrameRate * 2) : \
vinfps.ChangeFPS(OutputFrameRate * 2)
voutfps = OutputFrameRate <= Input.framerate ? \
vfps.BilinearResize(OutputWidth, OutputHeight) : \
vfps
vfields = voutfps.SeparateFields()
vlace = OutputTopFieldFirst ? \
vfields.SelectEvery(4, 1, 2) : \
vfields.SelectEvery(4, 0, 3)
# The ConvertToRGB() below is to work around a problem with the YUV to
# RGB conversion caused by a bug in one of the Microsoft DLLs. The
# bug makes the colors look bad. Your destination may bypass this
# conversion, so you may be able to remove this conversion in some
# cases.
#vout = vlace.Weave().ConvertToRGB()
#return(vout)

mg262
25th July 2005, 13:55
Both this and subsequent lines:

vpro = Input.SmoothDeinterlace(tff=InputTopFieldFirst, \
doublerate=true)

explicitly use Input as their video source. So you must put the converted video into Input. like this:

Input = AVISource("I:\Knight3.avi")
Input = ConvertToYUY2(Input)

or equivalently:

Input = AVISource("I:\Knight3.avi").ConvertToYUY2()

If you were just to try running that as a script on its own, it would give an error message (because there was no video being output from the last line), but it's fine as a fragment of a script like the one above, as long as the last line of the script returns some video. It looks to me like these should possibly be uncommented:

#vout = vlace.Weave().ConvertToRGB()
#return(vout)

so if it doesn't work, try this at the end

vout = vlace.Weave()#.ConvertToRGB()
vout

or if you want the RGB conversion

vout = vlace.Weave().ConvertToRGB()
vout

I do hope that helps! Shout if it doesn't fix things.

MarkTen
25th July 2005, 21:30
Hi mg262 the ammended script works a treat thank you :thanks:

Can I trouble you one last time. Before discovering this script and avs, I loaded my original ntsc mpeg into vdub mod telecined it to 23.97 and resized 720 x 480 to 720 x 576 and added black bars 720 x 48 top and bottom. Made it look better on my widescreen tv. Any chance you would know how to add this feature to the existing script and where might it go.

Really appreciate all your time and trouble :)

mg262
25th July 2005, 22:05
I loaded my original ntsc mpeg into vdub mod telecined it to 23.97 and resized 720 x 480 to 720 x 576 and added black bars 720 x 48 top and bottom.
I don't follow... I can understand how you could resize it, and I could understand how you could add black bars of those dimensions to go from 720 x 480 to 720 x 576, but I don't see how you could do both to the same clip...

Your output resolution is more or less fixed for DVD, but you can change the shape of the picture (or more precisely the aspect ratio), squashing it vertically so that for example it fits on a widescreen TV without any borders. The problem with doing this is that the whole picture will look squashed... and actually adding borders at the top and bottom instead of resizing will also make the picture look squashed because the PAL pixels are less tall than the NTSC ones.

So I don't quite follow what you're trying to do... but I have very little experience of this stuff, so I suspect someone else will be able to help more. Alternatively, you could look at the analog capture guide and read the section on aspect ratio, which is really pretty comprehensive.

In case you do want to try something, the AVISynth command is just AddBorders... you can look it up in the manual that comes with AVISynth. Putting it right at the end of the script, like this:

vout = vlace.Weave().ConvertToRGB()
vout = vout.AddBorders(0,48,0,48)
vout

should add those borders... but I would first go and read the analog capture guide and convince yourself that this is really what you want to do!

MarkTen
25th July 2005, 22:23
All I did with the 720 x 480 NTSC file was resize it to 576 by adding the black bars 48 top and bottom. If I just resize to 576 without adding bars and watch it on my 16:9 tv it looks wierd. But the black bars don't show on my 16:9 TV and the aspect ratio looks great, when I added the bars. But on my normal 4:3 TV you can see the black bars.

I will experiment thanks foryour help :p

mg262
25th July 2005, 22:47
Well, if you're happy with the look, try the three lines I gave you above (just replace the last couple of lines of the script with them); you will also have to set the 'outputheight' section of the script to 480 instead of 576 ... that's in this bit of script:

OutputWidth = Input.width
OutputHeight = 576

(if you didn't make the change, the script would resize to 576 and then add borders of 48 on top and bottom giving a height of 672...)

MarkTen
28th July 2005, 00:32
Thanks mg262 for all your help with this script. Everything is working great and I'm delighted with the output. Thanks again...