Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 27th December 2011, 16:59   #41  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 2,037
Maybe my post missed the thread, because Unipolator uses MFlowInter, not MVFlow.
I will open a new thread.

http://forum.doom9.org/showthread.php?p=1547405

This could help the attachment approval as well.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 31st December 2011, 06:16   #42  |  Link
Paazabel
Registered User
 
Join Date: Nov 2004
Location: St. Louis
Posts: 42
I'm a bit confused by where this thread leaves off. I'll say that my need matches the OP: I have been capturing analog tape (my God, will this stuff all just die, already?) and some of the sections of tape are not so great. I've got a top-notch VCR and know about head cleaning, but I'm still getting handfuls of herky-jerky dropped and/or inserted frames from time to time. A few spots, this is pretty disturbing, but in most cases, it is limited to one damaged field or frame at a time.

I have 160+ hours of this tape. Yeah. I really, really don't want to have to mark each bad frame and figure out what to do with it. I already have AVIsynth stuff set up to crop the garble off the bottom, do some VHS noise filtering, yadda, yadda, yadda. Would be nice if I had a method that says, "Oh, hey, that's a bad frame. How about we repeat the last one." Interpolating between frames is great, but just finding several hundred frames in the bazillion I'm going to be running into and making them not look like Max Headroom is plenty good enough for me.

Is that what this filter we are waiting for does?

Generating a list is okay, I guess. Doesn't this do what 2Bdecided is asking for? http://avisynth.org.ru/badframes/badframes.html
Paazabel is offline   Reply With Quote
Old 27th January 2012, 18:42   #43  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 206
One more Script...

Code:
#
#
# File: Interpolate_Bad_Frames.avs
# License GNU
# AviSynth 2.5.8
# VirtualDub 1.9.11
#
# Restore bad frames with interpolation
#
#
# Needed plugins and libruaries:
#   MVTools2
#   GScript
#   AVSLib (Array structure)
#
#
# You could write interpolation functions, see script code, up to 60 frames inc.
# This is the limit of the Array structure in the AVSLib.
#
#
# !!! No any checked in interpolate functions are done (Trim() function, see script code).
#
#



LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\GSCRIPT_11\gscript.dll")
LoadPackage("avslib", "array")



AVISource("01-build_avi_2000_Zelenograd_AVI.avi")   # Your input file is here


ConvertToYUY2()


Audio=GetChannel(last, 1, 2)
KillAudio()


function Interpolate(clip clp, int FrameNumber, int FrameInterpolate)
{
  # Constants
  # Change those constants to tune for the best result of interpolation
  #
  searchp = 2     # 2
  blks    = 32     # 8
  blksV   = 32     # 8
  hpad    = 2     # 4
  vpad    = 2	# 4
  pel     = 4     # 4

  tCD1    = 300   # 1500
  tCD2    = 128   # 130
  iml     = 70    # 70

  # Restore bad frames with interpolation with MFlowInter
  # Prepare functions
  #
  # function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
  #                 int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
  #
  super = MSuper(clp,           \
               hpad    = hpad,  \
               vpad    = vpad,  \
               pel     = pel,   \
               levels  = 0,     \
               chroma  = true,  \
               sharp   = 2,     \
               rfilter = 4,     \
               isse    = true,  \
               planar  = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  backward_vectors = MAnalyse(super,               \
                            blksize     = blks,    \
                            blksizeV    = blksV,   \
                            levels      = 0,       \
                            search      = 4,       \
                            searchparam = searchp, \  
                            pelsearch   = 2,       \
                            isb         = true,    \
                            lambda      = 0,       \
                            chroma      = true,    \
                            delta       = FrameInterpolate + 1, \
                            truemotion  = true,    \ 
                            lsad        = 1200,    \
                            plevel      = 0,       \
                            global      = true,    \
                            pnew        = 50,      \
                            pzero       = 50,      \
                            pglobal     = 0,       \
                            overlap     = 0,       \
                            overlapV    = 0,       \
                            dct         = 0,       \
                            divide      = 0,       \
                            sadx264     = 0,       \
                            badSAD      = 10000,   \
                            badrange    = 24,      \
                            isse        = true,    \
                            meander     = true,    \
                            temporal    = false,   \
                            trymany     = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  forward_vectors = MAnalyse(super,               \
                           blksize     = blks,    \
                           blksizeV    = blksV,   \
                           levels      = 0,       \
                           search      = 4,       \
                           searchparam = searchp, \  
                           pelsearch   = 2,       \
                           isb         = false,   \
                           lambda      = 0,       \
                           chroma      = true,    \
                           delta       = FrameInterpolate + 1, \
                           truemotion  = true,    \ 
                           lsad        = 1200,    \
                           plevel      = 0,       \
                           global      = true,    \
                           pnew        = 50,      \
                           pzero       = 50,      \
                           pglobal     = 0,       \
                           overlap     = 0,       \
                           overlapV    = 0,       \
                           dct         = 0,       \
                           divide      = 0,       \
                           sadx264     = 0,       \
                           badSAD      = 10000,   \
                           badrange    = 24,      \
                           isse        = true,    \
                           meander     = true,    \
                           temporal    = false,   \
                           trymany     = false)

  # Create an empty Array of clips
  #
  Array2 = ArrayCreate()

  # Fill an Array with the MFlowInter() clips with different times
  #
  GScript("""
  for (i=0, FrameInterpolate-1) {
    itime = (100.0 / Float(FrameInterpolate + 1)) * Float(i + 1)
    inter = MFlowInter(clp,              \
                       super,            \
                       backward_vectors, \
                       forward_vectors,  \
                       time   = itime,   \
                       mL     = iml,     \
                       blend  = true,    \
                       thSCD1 = tCD1,    \
                       thSCD2 = tCD2,    \
                       isse   = true,    \
                       planar = false)
    Array2 = Array2.ArrayInsert(inter, index=i)
  }      # End of For ()
  """)   # End of GScript ()

  # Get MFlowInter() clips with different times from array to do interpolated frames
  #
  GScript("""
  for (i=0, FrameInterpolate-1) {
    if (i == 0) {
      inter = Array2.ArrayGet(i).Trim(FrameNumber, -1)
    }
    else {
      inter = inter ++ Array2.ArrayGet(i).Trim(FrameNumber, -1)
    }
  }      # End of For ()
  """)   # End of GScript ()

  # Delete an Array of interpolate clips
  #
  GScript("""
  for (i=FrameInterpolate-1, 0, -1) {
    Array2 = Array2.ArrayDelete(index=i)
  }      # End of For ()
  """)   # End of GScript ()

  return (inter)
}



function OneFrame(clip clp, int N)
{
  # N is number of the frame in Source that needs replacing. 
  # Frame N  will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 1) ++ clp.trim(N + 1, 0)
}

function PairFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 2) ++ clp.trim(N + 2, 0)
}

function TwoFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 2) ++ clp.trim(N + 2, 0)
}

function ThreeFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 3) ++ clp.trim(N + 3, 0)
}

function FourFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 4) ++ clp.trim(N + 4, 0)
}

function FiveFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 5) ++ clp.trim(N + 5, 0)
}

function SixFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 6) ++ clp.trim(N + 6, 0)
}

function SevenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 7) ++ clp.trim(N + 7, 0)
}

function EightFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 8) ++ clp.trim(N + 8, 0)
}

function NineFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 9) ++ clp.trim(N + 9, 0)
}

function TenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 and N + 9 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 10) ++ clp.trim(N + 10, 0)
}

function SeventeenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 and N + 9 ... N + 17 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 17) ++ clp.trim(N + 17, 0)
}



# Restore bad frames (only for example)
#
OneFrame(10)            # 10 is bad frame
TwoFrames(20)           # 20, 21 are bad frames
ThreeFrames(30)         # 30, 31, 32 are bad frames
FourFrames(40)          # 40, 41, 42, 43 are bad frames
FIverames(50)           # 50, 51, 52, 53, 54 are bad frames
SixFrames(60)           # 60, 61, 62, 63, 64, 65 are bad frames
SevenFrames(70)         # 70, 71, 72, 73, 74, 75, 76 are bad frames
EightFrames(80)         # 80, 81, 82, 83, 84, 85, 86, 87 are bad frames
NineFrames(90)          # 90, 91, 92, 93, 94, 95, 96, 97, 98 are bad frames
TenFrames(100)          # 100, 101, 102, 103, 104, 105, 106, 107, 108, 109 are bad frames
SeventeenFrames(120)    # 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136 are bad frames



AudioDub(last, Audio)
__________________
Warm and fuzzy (white and fluffy)

Last edited by Jenyok; 27th January 2012 at 19:13.
Jenyok is offline   Reply With Quote
Old 30th January 2012, 19:13   #44  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 206
Restore "bad frames" with interpolation MFlowInter().
New version.

Code:
#
#
# Ver. 1.1
# 30.01.2012 year
#
#
# File: Interpolate_Bad_Frames.avs
# License GNU
# AviSynth 2.5.8
# VirtualDub 1.9.11
#
#
# Restore bad frames with interpolation
#
#
# Needed plugins and libruaries:
#   MVTools2
#   GScript
#   AVSLib (Array structure)
#
#
# You could write interpolation functions, see script code, up to 60 frames inc.
# This is the limit of the Array structure in the AVSLib.
#
#
# !!! No any checked in interpolate functions are done (Trim() function, see script code).
#
#



LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\GSCRIPT_11\gscript.dll")
LoadPackage("avslib", "array")



AVISource("01-build_avi_2000_Zelenograd_AVI.avi")   # Your input file is here


ConvertToYUY2()


Audio=GetChannel(last, 1, 2)
KillAudio()


function Interpolate(clip clp, int FrameNumber, int FrameInterpolate)
{
  # Constants
  # Change those constants to tune for the best result of interpolation
  #
  searchp = 2     # 2
  blks    = 32     # 8
  blksV   = 32     # 8
  hpad    = 2     # 4
  vpad    = 2	# 4
  pel     = 4     # 4

  tCD1    = 300   # 1500
  tCD2    = 128   # 130
  iml     = 70    # 70

  # Restore bad frames with interpolation with MFlowInter
  # Prepare functions
  #
  # function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
  #                 int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
  #
  super = MSuper(clp,           \
               hpad    = hpad,  \
               vpad    = vpad,  \
               pel     = pel,   \
               levels  = 0,     \
               chroma  = true,  \
               sharp   = 2,     \
               rfilter = 4,     \
               isse    = true,  \
               planar  = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  backward_vectors = MAnalyse(super,               \
                            blksize     = blks,    \
                            blksizeV    = blksV,   \
                            levels      = 0,       \
                            search      = 4,       \
                            searchparam = searchp, \  
                            pelsearch   = 2,       \
                            isb         = true,    \
                            lambda      = 0,       \
                            chroma      = true,    \
                            delta       = FrameInterpolate + 1, \
                            truemotion  = true,    \ 
                            lsad        = 1200,    \
                            plevel      = 0,       \
                            global      = true,    \
                            pnew        = 50,      \
                            pzero       = 50,      \
                            pglobal     = 0,       \
                            overlap     = 0,       \
                            overlapV    = 0,       \
                            dct         = 0,       \
                            divide      = 0,       \
                            sadx264     = 0,       \
                            badSAD      = 10000,   \
                            badrange    = 24,      \
                            isse        = true,    \
                            meander     = true,    \
                            temporal    = false,   \
                            trymany     = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  forward_vectors = MAnalyse(super,               \
                           blksize     = blks,    \
                           blksizeV    = blksV,   \
                           levels      = 0,       \
                           search      = 4,       \
                           searchparam = searchp, \  
                           pelsearch   = 2,       \
                           isb         = false,   \
                           lambda      = 0,       \
                           chroma      = true,    \
                           delta       = FrameInterpolate + 1, \
                           truemotion  = true,    \ 
                           lsad        = 1200,    \
                           plevel      = 0,       \
                           global      = true,    \
                           pnew        = 50,      \
                           pzero       = 50,      \
                           pglobal     = 0,       \
                           overlap     = 0,       \
                           overlapV    = 0,       \
                           dct         = 0,       \
                           divide      = 0,       \
                           sadx264     = 0,       \
                           badSAD      = 10000,   \
                           badrange    = 24,      \
                           isse        = true,    \
                           meander     = true,    \
                           temporal    = false,   \
                           trymany     = false)

  GScript("""
  if (FrameInterpolate == 1) {
    inter = MFlowInter(clp,              \
                       super,            \
                       backward_vectors, \
                       forward_vectors,  \
                       time   = 50,      \
                       mL     = iml,     \
                       blend  = true,    \
                       thSCD1 = tCD1,    \
                       thSCD2 = tCD2,    \
                       isse   = true,    \
                       planar = false)
    inter = inter.Trim(FrameNumber, -1)
  }        # End of If-Then
  else {
    # Create an empty Array of clips
    #
    Array2 = ArrayCreate()

    # Fill an Array with the MFlowInter() clips with different times
    #
    for (i=0, FrameInterpolate-1) {
      itime = (100.0 / Float(FrameInterpolate + 1)) * Float(i + 1)
      inter = MFlowInter(clp,              \
                         super,            \
                         backward_vectors, \
                         forward_vectors,  \
                         time   = itime,   \
                         mL     = iml,     \
                         blend  = true,    \
                         thSCD1 = tCD1,    \
                         thSCD2 = tCD2,    \
                         isse   = true,    \
                         planar = false)
      Array2 = Array2.ArrayInsert(inter, index=i)
    }      # End of For ()

    # Get MFlowInter() clips with different times from array to do interpolated frames
    #
    for (i=0, FrameInterpolate-1) {
      if (i == 0) {
        inter = Array2.ArrayGet(i).Trim(FrameNumber, -1)
      }
      else {
        inter = inter ++ Array2.ArrayGet(i).Trim(FrameNumber, -1)
      }
    }      # End of For ()

    # Delete an Array of interpolate clips
    #
    for (i=FrameInterpolate-1, 0, -1) {
      Array2 = Array2.ArrayDelete(index=i)
    }      # End of For ()
  }        # End of If-Else
  """)     # End of GScript ()

  return (inter)
}



function OneFrame(clip clp, int N)
{
  # N is number of the frame in Source that needs replacing. 
  # Frame N  will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 1) ++ clp.trim(N + 1, 0)
}

function PairFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 2) ++ clp.trim(N + 2, 0)
}

function TwoFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 2) ++ clp.trim(N + 2, 0)
}

function ThreeFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 3) ++ clp.trim(N + 3, 0)
}

function FourFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 4) ++ clp.trim(N + 4, 0)
}

function FiveFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 5) ++ clp.trim(N + 5, 0)
}

function SixFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 6) ++ clp.trim(N + 6, 0)
}

function SevenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 7) ++ clp.trim(N + 7, 0)
}

function EightFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 8) ++ clp.trim(N + 8, 0)
}

function NineFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 9) ++ clp.trim(N + 9, 0)
}

function TenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 and N + 9 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 10) ++ clp.trim(N + 10, 0)
}

function SeventeenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 and N + 9 ... N + 17 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 17) ++ clp.trim(N + 17, 0)
}



# Restore bad frames (only for example)
#
OneFrame(10)            # 10 is bad frame
TwoFrames(20)           # 20, 21 are bad frames
ThreeFrames(30)         # 30, 31, 32 are bad frames
FourFrames(40)          # 40, 41, 42, 43 are bad frames
FIverames(50)           # 50, 51, 52, 53, 54 are bad frames
SixFrames(60)           # 60, 61, 62, 63, 64, 65 are bad frames
SevenFrames(70)         # 70, 71, 72, 73, 74, 75, 76 are bad frames
EightFrames(80)         # 80, 81, 82, 83, 84, 85, 86, 87 are bad frames
NineFrames(90)          # 90, 91, 92, 93, 94, 95, 96, 97, 98 are bad frames
TenFrames(100)          # 100, 101, 102, 103, 104, 105, 106, 107, 108, 109 are bad frames
SeventeenFrames(120)    # 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136 are bad frames



AudioDub(last, Audio)
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 30th January 2012, 19:43   #45  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 206
One more and more script.
Very new version.

Code:
#
#
# Ver. 1.2
# 30.01.2012 year
#
#
# File: Interpolate_Bad_Frames.avs
# License GNU
# AviSynth 2.5.8
# VirtualDub 1.9.11
#
#
# Restore bad frames with interpolation
#
#
# Needed plugins and libruaries:
#   MVTools2
#   GScript
#
#
# You could write interpolation functions, see script code, up to 60 frames inc.
# This is the limit of the Array structure in the AVSLib.
#
#
# !!! No any checked in interpolate functions are done (Trim() function, see script code).
#
#



LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\GSCRIPT_11\gscript.dll")



AVISource("01-build_avi_2000_Zelenograd_AVI.avi")   # Your input file is here


ConvertToYUY2()


Audio=GetChannel(last, 1, 2)
KillAudio()


function Interpolate(clip clp, int FrameNumber, int FrameInterpolate)
{
  # Constants
  # Change those constants to tune for the best result of interpolation
  #
  searchp = 2     # 2
  blks    = 32     # 8
  blksV   = 32     # 8
  hpad    = 2     # 4
  vpad    = 2	# 4
  pel     = 4     # 4

  tCD1    = 300   # 1500
  tCD2    = 128   # 130
  iml     = 70    # 70

  # Restore bad frames with interpolation with MFlowInter
  # Prepare functions
  #
  # function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
  #                 int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
  #
  super = MSuper(clp,           \
               hpad    = hpad,  \
               vpad    = vpad,  \
               pel     = pel,   \
               levels  = 0,     \
               chroma  = true,  \
               sharp   = 2,     \
               rfilter = 4,     \
               isse    = true,  \
               planar  = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  backward_vectors = MAnalyse(super,               \
                            blksize     = blks,    \
                            blksizeV    = blksV,   \
                            levels      = 0,       \
                            search      = 4,       \
                            searchparam = searchp, \  
                            pelsearch   = 2,       \
                            isb         = true,    \
                            lambda      = 0,       \
                            chroma      = true,    \
                            delta       = FrameInterpolate + 1, \
                            truemotion  = true,    \ 
                            lsad        = 1200,    \
                            plevel      = 0,       \
                            global      = true,    \
                            pnew        = 50,      \
                            pzero       = 50,      \
                            pglobal     = 0,       \
                            overlap     = 0,       \
                            overlapV    = 0,       \
                            dct         = 0,       \
                            divide      = 0,       \
                            sadx264     = 0,       \
                            badSAD      = 10000,   \
                            badrange    = 24,      \
                            isse        = true,    \
                            meander     = true,    \
                            temporal    = false,   \
                            trymany     = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  forward_vectors = MAnalyse(super,               \
                           blksize     = blks,    \
                           blksizeV    = blksV,   \
                           levels      = 0,       \
                           search      = 4,       \
                           searchparam = searchp, \  
                           pelsearch   = 2,       \
                           isb         = false,   \
                           lambda      = 0,       \
                           chroma      = true,    \
                           delta       = FrameInterpolate + 1, \
                           truemotion  = true,    \ 
                           lsad        = 1200,    \
                           plevel      = 0,       \
                           global      = true,    \
                           pnew        = 50,      \
                           pzero       = 50,      \
                           pglobal     = 0,       \
                           overlap     = 0,       \
                           overlapV    = 0,       \
                           dct         = 0,       \
                           divide      = 0,       \
                           sadx264     = 0,       \
                           badSAD      = 10000,   \
                           badrange    = 24,      \
                           isse        = true,    \
                           meander     = true,    \
                           temporal    = false,   \
                           trymany     = false)

  GScript("""
  if (FrameInterpolate == 1) {
    inter2 = MFlowInter(clp,              \
                        super,            \
                        backward_vectors, \
                        forward_vectors,  \
                        time   = 50,      \
                        mL     = iml,     \
                        blend  = true,    \
                        thSCD1 = tCD1,    \
                        thSCD2 = tCD2,    \
                        isse   = true,    \
                        planar = false)
    inter = inter2.Trim(FrameNumber, -1)
  }        # End of If-Then
  else {
    # Fill an Inter variable with the MFlowInter() clips with different times
    # Times are calculated in each step
    #
    for (i=0, FrameInterpolate-1) {
      itime = (100.0 / Float(FrameInterpolate + 1)) * Float(i + 1)
      inter2 = MFlowInter(clp,              \
                          super,            \
                          backward_vectors, \
                          forward_vectors,  \
                          time   = itime,   \
                          mL     = iml,     \
                          blend  = true,    \
                          thSCD1 = tCD1,    \
                          thSCD2 = tCD2,    \
                          isse   = true,    \
                          planar = false)
      if (i == 0) {
        inter = inter2.Trim(FrameNumber, -1)
      }    # End of If-Then
      else {
        inter = inter ++ inter2.Trim(FrameNumber, -1)
      }    # End of If-Else
    }      # End of For ()
  }        # End of If-Else
  """)     # End of GScript ()

  return (inter)
}



function OneFrame(clip clp, int N)
{
  # N is number of the frame in Source that needs replacing. 
  # Frame N  will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 1) ++ clp.trim(N + 1, 0)
}

function PairFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 2) ++ clp.trim(N + 2, 0)
}

function TwoFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 2) ++ clp.trim(N + 2, 0)
}

function ThreeFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 3) ++ clp.trim(N + 3, 0)
}

function FourFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 4) ++ clp.trim(N + 4, 0)
}

function FiveFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 5) ++ clp.trim(N + 5, 0)
}

function SixFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 6) ++ clp.trim(N + 6, 0)
}

function SevenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 7) ++ clp.trim(N + 7, 0)
}

function EightFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 8) ++ clp.trim(N + 8, 0)
}

function NineFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 9) ++ clp.trim(N + 9, 0)
}

function TenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 and N + 9 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 10) ++ clp.trim(N + 10, 0)
}

function SeventeenFrames(clip clp, int N)
{
  # N is number of the first frame in Source that needs replacing. 
  # Frames N and N + 1 and N + 2 and N + 3 and N + 4 and N + 5 and N + 6 
  # and N + 7 and N + 8 and N + 9 ... N + 17 (O) will be replaced.
	
  clp.trim(0, N - 1) ++ Interpolate(clp, N - 1, 17) ++ clp.trim(N + 17, 0)
}



# Restore bad frames (only for example)
#
OneFrame(10)            # 10 is bad frame
TwoFrames(20)           # 20, 21 are bad frames
ThreeFrames(30)         # 30, 31, 32 are bad frames
FourFrames(40)          # 40, 41, 42, 43 are bad frames
FIverames(50)           # 50, 51, 52, 53, 54 are bad frames
SixFrames(60)           # 60, 61, 62, 63, 64, 65 are bad frames
SevenFrames(70)         # 70, 71, 72, 73, 74, 75, 76 are bad frames
EightFrames(80)         # 80, 81, 82, 83, 84, 85, 86, 87 are bad frames
NineFrames(90)          # 90, 91, 92, 93, 94, 95, 96, 97, 98 are bad frames
TenFrames(100)          # 100, 101, 102, 103, 104, 105, 106, 107, 108, 109 are bad frames
SeventeenFrames(120)    # 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136 are bad frames



AudioDub(last, Audio)
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 1st February 2012, 13:53   #46  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
Quote:
Originally Posted by Paazabel View Post
Doesn't this do what 2Bdecided is asking for? http://avisynth.org.ru/badframes/badframes.html
No, because though it says blend is "interpolation", it's really just a blend - i.e. overlaying the two frames either side of the bad one. No mvtools or motion compensation involved.


The scripts from Emulgator and Jenyok both seem to do what's required, using different syntaxes. Neither matches the generic "list the frames you want replacing" syntax of badframes. If they did, they would be ideal.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 1st February 2012, 14:04   #47  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
2Bdecided, how about my solution from post #34?
Admittedly, it does not deal intelligently with consecutive bad frames, as each frame is interpolated only from its previous and next neighbours.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 2nd February 2012, 12:04   #48  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
Quote:
Originally Posted by Gavino View Post
2Bdecided, how about my solution from post #34?
Admittedly, it does not deal intelligently with consecutive bad frames, as each frame is interpolated only from its previous and next neighbours.
I overlooked that as I was working on something with consecutive bad frames. But now I'm working on something with isolated bad frames, that's great! Thanks Gavino.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 7th February 2012, 12:51   #49  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 269
Quote:
Originally Posted by Paazabel View Post

I have 160+ hours of this tape. Yeah. I really, really don't want to have to mark each bad frame and figure out what to do with it. I already have AVIsynth stuff set up to crop the garble off the bottom, do some VHS noise filtering, yadda, yadda, yadda. Would be nice if I had a method that says, "Oh, hey, that's a bad frame. How about we repeat the last one."

Yeah, there's basically two steps to the problem, and we have lots of options for how to tackle step 2 (creating a replacement frame), and none for step 1 (how to *detect* a frame that needs replacing).

The problem here is that there is no generalised meaning of the phrase "bad frame". Frames can go bad in so many different ways: Dissolving into white noise; Jumping up and down; going blank; or being replaced by a copy of the last "good" frame (which might not be *that* good anyway) because the capture device lost the incoming analog signal; and so on.

So you need to look at your source tape/capture and figure out: What is the most common way that frames go "bad" on this one? How can I build a detector for that situation, that won't misinterpret perfectly legitimate frames as bad ones?

For example, if the main problem is vertical off-locks, then you could use MVTools2 to detect cases where the picture information suddenly moves upward/downward in one frame, and back again a frame or two later. (We added the "one dimensional" search modes to MVTools2 specifically to speed up jobs like that. There's one that looks for vertical-only movement and one for horizontal-only; They're much faster than the general movement detection modes).

The closest I can get to a generalised approach to "bad frame" detection is really "unique" or "very unusual" frame detection: You basically compare each frame with it's immediate neighbours in various ways and raise a flag if it seems very different to *both*. (If it's different to one neighbour but very similar to the other, then it's a probably just a scene change.)

Maybe there would be value in a "FindWeirdFrame" function, with options to tell it to look for various common types of weirdness? It could either output a list of suspect frames, to be checked manually (if you have time) and then passed to the other tools mentioned in this thread, or it could be coded to use appropriate techniques to tackle each type of "weirdness" that it finds.

I will ponder upon this...
pbristow is offline   Reply With Quote
Old 7th February 2012, 14:17   #50  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 206
pbristow

Only human eye(s) could see "bad frame(s)",
only human brain could decide which frame(s) is bad or not...
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 7th February 2012, 16:45   #51  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 269
Quote:
Originally Posted by Jenyok View Post
pbristow

Only human eye(s) could see "bad frame(s)",
only human brain could decide which frame(s) is bad or not...
...If you don't define things any better than "bad frame", then yes. That was basically my starting point.

However, you can get a computerised process to help find bad frames, *if* you can define what particular kind of "badness" you want it to look for.

But if you try to search for "anything a human viewer will percieve as a bad frame", then... Nope, can't be done. (Not least because not all human viewers will agree on what *is* a bad frame anyway! )
pbristow is offline   Reply With Quote
Old 28th February 2012, 18:50   #52  |  Link
sven_x
Registered User
 
Join Date: Oct 2011
Location: Germany
Posts: 39
MorphDups - replace duplicate frames by interpolations
MorphDups is a script, that searches for duplicate frames. From the result it generates a second script, that is using calls to Mug Funky's Morph function which then replaces the duplicate frames by interpolations.

Last edited by sven_x; 8th March 2012 at 16:24.
sven_x is offline   Reply With Quote
Old 25th March 2012, 22:05   #53  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Hi,

I'm using InterpolateBadFrames for replacing broken frames from VHS captures. Or trying to without luck so far:

Code:
function R(clip Source, int N)
{
 # N is number of the frame in Source that needs replacing. 
 # Frame N  will be replaced.
 
 Source.trim(0,-N) ++ CandidatesForC.trim(N-1,-1) ++ Source.trim(N+1,0)
}


function RP(clip Source, int N)
{
 # N is number of the first frame in Source that needs replacing. 
 # Frames N and N+1(O) will be replaced.
 
 Source.trim(0,-N) ++ CandidatesForN.trim(N-1,-1) \
    ++ CandidatesForO.trim(N-1,-1) ++ Source.trim(N+2,0)
}


function RX(clip Source, int N, int X)
{
 # N is number of the 1st frame in Source that needs replacing. 
 # X is total number of frames to replace
 #e.g. RX(101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for mflowfps interpolation
 
start=Source.trim(N-1,-1) #one good frame before, used for interpolation reference point
end=Source.trim(N+X,-1) #one good frame after, used for interpolation reference point
 
start+end
AssumeFPS(1) #temporarily FPS=1 to use mflowfps
  
super = MSuper()
backward_vec = MAnalyse(super, isb = true)
forward_vec = MAnalyse(super, isb = false)
MFlowFps(super, backward_vec, forward_vec, blend=false, num=X+1, den=1) #num=X+1
AssumeFPS(FrameRate(Source)) #return back to normal source framerate for joining
Trim(1, framecount-1) #trim ends, leaving replacement frames
  
Source.trim(0,-N) ++ last ++ Source.trim(N+X+1,0)
}






###
#####interpolate bad frames and residual cleaning
###

Super = msuper()
bv1 = manalyse(Super, isb=true, delta=2)
fv1 = manalyse(Super, isb=false, delta=2)
bv2 = manalyse(Super, isb=true, delta=3)
fv2 = manalyse(Super, isb=false, delta=3)
global  CandidatesForN = mflowinter(Super, bv2, fv2, time=33.3, ml=100)
global  CandidatesForO = mflowinter(Super, bv2, fv2, time=66.7, ml=100)
global   CandidatesForC = mflowinter(Super, bv1, fv1, time=50.0, ml=100)

last
#rx(104,12) #104-116 replaced
I get the error message:

Quote:
AviSynth open failure:
Script error: Invalid arguments to function "msuper"
InterpolateBadFrames.avs line 55
I've tried a couple of different versions of MVTools2 but it doesn't make any difference. Is there anything obviously wrong with the script that anyone can see? I've tried several other multiple sequential frame replacers from this thread and elsewhere which either don't work so well or are impossibly complicated to use (for me) and was hoping to get this one going to see how it does. So far, for me the only one of these that does a good job is Gavino's FixBadFrames, but it only works on single frames.
manono is offline   Reply With Quote
Old 26th March 2012, 00:24   #54  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
Quote:
Originally Posted by manono View Post
Is there anything obviously wrong with the script that anyone can see?
The script is incomplete. You need to add your source filter:
Code:
function R(clip Source, int N)
{
 ...
}

function RP(clip Source, int N)
{
...
}

function RX(clip Source, int N, int X)
{
...
}

<------ Your source goes here, eg AviSource("myvid.avi")

###
#####interpolate bad frames and residual cleaning
###

Super = msuper()
...
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 26th March 2012, 04:46   #55  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Thanks for the response. I wasn't clear about how I'm doing this. I'm importing the function as an AVS and then calling it in the script:

LoadPlugin("C:\Path\To\MVTools2.dll")
Import("C:\Path\To\InterpolateBadFrames.avs")
AVISource("C:\Path\To\Movie.avi")
rx(104,12) #104-116 replaced

However, even when I do it as you suggest, using it as the main script and adding in the AviSource line where you said, I still get the MVTools2 msuper error.
manono is offline   Reply With Quote
Old 26th March 2012, 10:09   #56  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
Quote:
Originally Posted by manono View Post
even when I do it as you suggest, using it as the main script and adding in the AviSource line where you said, I still get the MVTools2 msuper error.
Odd, I don't see why it shouldn't work.

Your initial approach should also work (with the original avs) if you put the Import call after the source filter, ie
LoadPlugin("C:\Path\To\MVTools2.dll")
AVISource("C:\Path\To\Movie.avi")
Import("C:\Path\To\InterpolateBadFrames.avs")
rx(104,12) #104-116 replaced

Note also that if you are only using function rx, you can delete the script lines (starting from the offending Super=msuper()) at the end of the avs, as they set up globals only needed for functions R and RP.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 26th March 2012, 13:30   #57  |  Link
cobo
Registered User
 
Join Date: Mar 2004
Posts: 118
@manono
I tried your script and it's working without error with both mvtools 2,5,11.0 and 2.6.0.0, but instead of interpolating
it results in a freezeframe of the previous frame for the number of frames specified.

Mug Funkys Morph function works well and is easy to use. I find the interpolation is better with blocksize 32
and thSDC1 set to 800, so I use this:

Code:
# http://forum.doom9.org/showthread.php?t=161154
# morph by Mug Funky
# usage:
# if you have, say, frames 21 and 22 bad, then use "morph(20,23)"
# 

function morph (clip c, int in, int "out", int "blksize")
{

	Function fill_loop(string s, int stop, int count)
	{
		return (stop == 0) ? s : string("tofill.mflowinter(morph_spr,fill_vb,fill_vf,time=" + string(100*(count - stop)/float(count))) + ",thscd1=800,thscd2=255).selectevery(tofill.framecount(),0)," + fill_loop(s,stop-1,count)

		#return (stop == 0) ? s : string("tofill.mflowinter(morph_spr,fill_vb,fill_vf,time=" + string(100*(count - stop)/float(count))) + ",thscd1=255,thscd2=255).selectevery(tofill.framecount(),0)," + fill_loop(s,stop-1,count)
	}

out=default(out, 0)
blksize=default(blksize,32)

d=c.trim(in,out)# in-1?

numframes=d.framecount-2
tofill=d.selectevery(c.framecount(),0,c.framecount()-1)
global morph_spr=tofill.msuper()
fill_vf=morph_spr.manalyse(truemotion=true,blksize=blksize,isb=false,overlap=blksize/2)
fill_vb=morph_spr.manalyse(truemotion=true,blksize=blksize,isb=true,overlap=blksize/2)
filled=eval("interleave(" + fill_loop("" ,d.framecount()-1,d.framecount()-1) + "tofill.selectevery(tofill.framecount(),tofill.framecount())).assumefps(c.framerate())")
c.trim(0,-(in+1))++filled.trim(1,numframes)++c.trim(out,0)
}

Last edited by cobo; 26th March 2012 at 13:35.
cobo is offline   Reply With Quote
Old 26th March 2012, 16:56   #58  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
Quote:
Originally Posted by cobo View Post
I tried your script and it's working without error with both mvtools 2,5,11.0 and 2.6.0.0, but instead of interpolating it results in a freezeframe of the previous frame for the number of frames specified.
Well, I just tried it and it definitely interpolates.
However the comment beside the function call is slightly wrong.
rx(104,12) actually replaces frames 104-115 (by gradual interpolation between 103 and 116).
The comment in the function itself is correct.
__________________
GScript and GRunT - complex Avisynth scripting made easier

Last edited by Gavino; 26th March 2012 at 16:59.
Gavino is offline   Reply With Quote
Old 26th March 2012, 22:53   #59  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Thanks to you both. I finally got it working by taking Gavino's suggestion to import it after opening the AVI. Thanks a lot for that as I never would have figured it out on my own.

Cobo, I've been using Mug Funky's Morph before now but don't much like it for several reasons, both trivial and important. The important one is the fact if I try to call it more than a dozen-15 times in the script, I get an out of memory error. So the movie has to be broken up into pieces, encoded separately as lossless, and then rejoined. And like the other frame interpolators (except Gavino's FixBadFrames for single isolated frames), a line has to be written for each instance you use it. And you also have to plug in the frame numbers before and after the frames that actually need fixing, something I find counterintuitive and annoying. This InterpolateBadFrames seems to behave in the same way. One should be able to both write in only the frames needing fixing, and be able to do it within a single all-encompassing line, something like:

FixAllBadFrames([21 21] [50 51] [100 104] [200 208] [300 302])

where the frame numbers are the first and last needing fixing. Something like that. "OK, manono, if you're so particular write the function to suit yourself." If only. Plus, Gavino has explained to me outside this thread that is a very difficult, if not impossible, thing to accomplish. Thanks again.
manono is offline   Reply With Quote
Old 27th March 2012, 06:41   #60  |  Link
cobo
Registered User
 
Join Date: Mar 2004
Posts: 118
It looks like I'm only getting the freezeframe effect when using FFmpegSource2 with H264 or mpeg2, otherwise the script interpolates as it should. The script works no matter where I put the source or import the avs.

I don't get an out of memory error even with dozens of morph calls. Can you use more than 15 calls of the RX function without getting the out of memory error?
cobo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.