VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy PlayOn and record Netflix! :)
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. I have friends with home movies from overseas that they want to view here in the U.S. There are some solutions to this, but I think the lack of a free way to convert video from one standard to another needs to be corrected. To that end I created the script below. Give it a try and see what you think.

    Please note: THIS IS FOR INTERLACED VIDEO SOURCE. That means it IS NOT for movies/film. That means it IS NOT appropriate for most DVDs, DivX, etc. (Even much prime-time content is shot on film.) For those sources, you can do much better than this script! This script is mostly useful for HOME MOVIES (shot on a camcorder) or live sporting events (OK, maybe soap operas ). The output can be converted to any format your system can support, such as SVCD or DVD (there are better ways to convert to VCDs, since they is not interlaced). I have also converted the output to miniDV format and exported it on tape via IEEE-1394 for archiving.

    To use the script, cut and paste the text below into a text file (using something like Notepad), but use the .AVS extension instead of .TXT (the indentation is lost by posting the script this way, but it should still work). Once you have all the parts installed (see the comments below) and have made the necessary modifications to the script for your particular system, just open the .AVS file in your favorite video program (CCE, TMPGEnc, VirtualDub, etc.) and create your output file as desired (encode, frame server, save as..., etc.).

    Xesdeeni
    (Xesdeeni2001 at the Yahoo mail server)

    ################################################## ############################
    #
    # 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 with reasonable quality.
    #
    # NOTE: This script is NOT meant to convert telecined films (that is, films
    # in NTSC video format using 3:2 pulldown, or films in PAL video format
    # speeding the 24fps to 25fps). It is best for content like HOME MOVIES shot
    # with camcorders or live sporting events.
    #
    ################################################## ############################
    #
    # This script is for use with AVISynth version 1.0 beta 3 or above.
    #
    # This script uses Gunnar Thalin's area-based deinterlace plugin for
    # VirtualDub, available at http://home.bip.net/gunnart/video/#deinterlacearea.
    #
    ################################################## ############################
    #
    # USE:
    #
    # 1. Modify the "global" line below for your environment.
    # 2. Modify the last lines of the file for your desired conversion.
    #
    ################################################## ############################
    #
    # For comments/suggestions email Xesdeeni2001 at the Yahoo mail server.
    #
    ################################################## ############################

    global PluginPath = "E:\VirtualDub\Plugins"

    #
    # VideoConvert()
    #
    # Function to convert one INTERLACED video format to another INTERLACED video
    # format.
    #
    # The function works by first converting the input video from interlaced to
    # progressive using an adaptive deinterlacer. Then the progressive frame rate
    # is converted to a progressive frame rate that is the same as the output
    # field rate. Finally the progressive frames are converted back to interlace
    # for output. Scaling is also performed where appropriate.
    #
    function VideoConvert(clip clip, \
    float OutputFrameRate, \
    int OutputFrameWidth, \
    int OutputFrameHeight)
    {
    LoadVirtualDubPlugin(PluginPath + "\DeinterlaceAreaBased.vdf", \
    "AreaBasedDeinterlace", \
    1)

    #
    # Get input video parameters
    #
    InputFrameRate = clip.framerate
    InputFrameWidth = clip.width
    InputFrameHeight = clip.height
    InputFrameCount = clip.framecount
    InputFieldRate = InputFrameRate * 2

    #
    # Get output video parameters
    #
    OutputFieldRate = OutputFrameRate * 2
    OutputFrameCount = \
    round(InputFrameCount * (OutputFrameRate / InputFrameRate))

    # Input video is clip supplied
    v1 = clip

    # When the output frame count is greater than the input frame count, due to
    # a problem with AVISynth, the output video is truncated so that it only has
    # as many frames as the input video. Here we work around this issue by
    # adding enough black frames to ensure all the frames are available on the
    # output.
    v2 = OutputFrameCount > InputFrameCount ? \
    v1 + v1.Blackness(OutputFrameCount - InputFrameCount) : \
    v1

    # The deinterlacer will be set to interpolate missing lines instead of
    # blending the fields, where motion is detected (I think this looks better).
    # But the deinterlacer can only use one of the fields for this. If we
    # leave this as-is, on video in motion, we'll only get one position for
    # each pair of fields. Instead, we want one position for every field.
    # To do this, we'll use the deinterlacer twice on the same pair of fields
    # and interleave the results below. But in order for the deinterlacer to
    # use different fields in each case, we need to effectively reverse the
    # field polarity for one of our streams. The way I decided to do this was
    # to add an extra line to the top of the image, moving each line down.
    # The total number of lines must stay even, so I also add a line to the
    # bottom.
    v3 = v2
    v4 = v2.AddBorders(0,7,0,9)

    # Each of our two streams is deinterlaced here. Because the deinterlacer
    # is a VirtualDub plugin, it requires RGB data.
    v5 = v3.ConvertToRGB().AreaBasedDeinterlace(0, 0, 27, 25)
    v6 = v4.ConvertToRGB().AreaBasedDeinterlace(0, 0, 27, 25)

    # Now we have to remove the extra two lines we added above.
    v7 = v5
    v8 = v6.Crop(0,7,InputFrameWidth,InputFrameHeight)

    # Here we alternate frames between the two streams we created above in order
    # to produce a progressive stream with the same number of full frames as
    # we originally had fields.
    v9 = Interleave(v7,v8 )

    # If we have more frames on the output than on the input, it is more
    # efficient to scale here.
    v10 = InputFrameRate <= OutputFrameRate ? \
    v9.BicubicResize(OutputFrameWidth, OutputFrameHeight) : \
    v9

    # Using AVISynth's built-in filter, we either repeat or drop frames to
    # get the appropriate output frame rate.
    v11 = v10.ChangeFPS(OutputFieldRate)

    # If we have fewer frames on the output than on the input, it is more
    # efficient to scale here.
    v12 = InputFrameRate > OutputFrameRate ? \
    v11.BicubicResize(OutputFrameWidth, OutputFrameHeight) : \
    v11

    # Now we convert our video back to interlace by separating the fields,
    # throwing out one from each progressive frame, and weaving the results
    # together.
    v13 = v12.SeparateFields().SelectEvery(4,0,3).Weave()

    # When the output frame count is less than the input frame count, due to
    # a problem with AVISynth, the output video is extended so that it has
    # as many frames as the input video. Here we work around this issue by
    # trimming the extra frames.
    v14 = OutputFrameCount < InputFrameCount ? \
    v13.Trim(0, OutputFrameCount - 1) : \
    v13

    return(v14)
    }

    #
    # Convert INTERLACED NTSC video to INTERLACED PAL video
    #
    function NTSCToPAL(clip clip)
    {
    return(VideoConvert(clip, 25, 720, 576))
    }

    #
    # Convert INTERLACED PAL video to INTERLACED NTSC video
    #
    function PALToNTSC(clip clip)
    {
    return(VideoConvert(clip, 29.97, 720, 480))
    }

    ################################################## ############################
    #
    # Uncomment ONE of the following lines and replace the file name with yours.
    #

    NTSCToPAL(AVISource("LiveTest.avi"))
    #PALToNTSC(AVISource("LiveTest(ConvertedToPAL).avi "))
    Quote Quote  
  2. I'm trying to get it to work but i get alot of script errors when opening the avs in VD =/
    can you please check your scripting again?
    Quote Quote  
  3. I cut and pasted the post back into Notepad and tried the script. It worked fine (I actually did this with the Preview before I posted it, but I tried again just now to be sure). What specific errors are you seeing? Can you share your modified lines? What are the specs of your source video?

    Xesdeeni
    Quote Quote  
  4. Member
    Join Date
    Nov 2001
    Location
    United States
    Search Comp PM
    Can you post a similar script for movie conversions from pal to ntsc?
    Quote Quote  
  5. Awesome post! Thanks for your hard work -- it's much better than the other PAL to NTSC script I had! Worked perfectly!
    your pal,
    Stinky
    Quote Quote  



Similar Threads