AVISynth Scenarios
Page Contents
•
Frame Interpolation with RIFE
•
Chroma Bleed in ANIME video
•
Removing Aliasing from Progressive video (Jagged edging)
•
IVTC 3:2 Pulldown of MPEG2 in MKV
•
PSF Cleanup (VOB)
•
Anime aliasing and frame blending
•
Removing duplicates from a Bluray rip of an old film
•
Correcting a 59.94 capture back to 29.97
•
Correcting hard-coded Wrong field Order
•
Dealing with WMVs
•
Old 320x240 Digital Camera Video Files
•
Detecting Duplicated Frames
Frame Interpolation with RIFE
Note: RIFE only operates on a 64bit system with the latest graphic cards.
RIFE is a high-quality frame interpolation filter, meaning it will smooth out videos by re/creating frames that are missing,
such as after duplicated or blended frames have been removed by other filters, for example when processing cine film
that has been captured by a video camera (telecine). It will interpolate between two frames and create an in-between
frame. This results in smoother video.
The RIFE filter comprises two parts: the filter files themselves, which are included in the plugins folder in the above zip
package, and the RIFE models, which are a 1GB collection of files and folders which detail the various models. I
haven’t included the models folder in the above download because of it’s size; if you would like to use RIFE:
•
go to the Github RIFE page
•
click on the “Latest” button on the right
•
click on the link to the models to download the zipped models folder.
Assuming you have set up AVISynth as I have described above, the models folder needs to be placed in the
avisynth+\plugins64+ folder:
The actual model number to be used in the AVISynth script is shown against the folder number is shown lower down on
the Github page linked-to above. For example, folder 4.6 (True) is model number 24.
Note: only models using 4.1 and above will allow adjustment/manual setting of the frame rate. Lower models will only
double the original framerate.
A typical RIFE script would look something like this, with the user-variables in blue:
v=ffms2("H:\Magix Info\Jak\Deinterlaced 00059.m2ts")
a=LWLibavAudioSource("H:\Magix Info\Jak\Deinterlaced 00059.m2ts")
AudioDub(v,a)
# RIFE only works with RGB floats
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f")
# motion interpolate to 50 fps
Rife(gpu_thread=1, model=11, fps_num=50000, fps_den=1000, sc=true, sc_threshold=0.12)
# back to YV12
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:f=>709:709:709:l")
RIFE Notes
•
If you find that RIFE is not interpolating during rapid panning, try setting the “sc=” to false, or if a scene change is in
play, use sc1=True. Sc=True leaves duplicates at the scene change. Sc1=True blends the duplicate with the first
frame of the new scene.
Chroma Bleed in ANIME video
https://forum.videohelp.com/threads/416462-How-to-remove-this-interlace-blending-chroma-bleed
Removing Aliasing from Progressive video (Jagged edging)
https://forum.videohelp.com/threads/416435-Which-copy-looks-better-to-you-Attachments#post2756412
VHS Capture of DVD restoration (file 2)
https://forum.videohelp.com/threads/416923-De-Interlacing-another-DVD-from-collection
Another capture (file 1):
https://forum.videohelp.com/threads/416904-De-Interlacing-DVD-and-changing-25FPS-To-24FPS
IVTC 3:2 Pulldown of MPEG2 in MKV
Ref: Davexnet https://forum.videohelp.com/threads/404621-MakeMKV/page2#post2762453
aud=ffaudiosource("D:\VH\Chris Hooper\A1_t00.mkv",track=-1)
vid=ffvideosource("D:\VH\Chris Hooper\A1_t00.mkv", track=-1, seekmode=1,fpsnum=30000,fpsden=1001)
audiodub(vid,aud)
tfm().tdecimate()
Prefetch(24)
PSF Cleanup (VOB)
Ref Davexnet
v=ffms2("D:\VH\Akuma786\30Dec\VTS_01_1.VOB")
a=LWLibavAudioSource("D:\VH\Akuma786\30Dec\VTS_01_1.VOB")
AudioDub(v,a)
qtgmc(inputtype=2,preset="medium")
crop(0,124,-0,-122)
depansafe(dxmax=4,dymax=4)
crop(2,6,-4,-8)
Anime aliasing and frame blending
https://forum.videohelp.com/threads/417775-Difficult-low-quality-telecined-source
Removing duplicates from a Bluray rip of an old film
https://forum.videohelp.com/threads/418061-Solutions-for-a-film-with-duplicate-frames-without-predictable-
cycle#post2772415
Uses TDecimate(cycle=25,cycleR=3) to remove dupes and return frame rate back to original of 22fps.
Correcting a 59.94 capture back to 29.97
https://forum.videohelp.com/threads/418065-Converting-wrongly-captured-59-94fps-to-29-97fps#post2772420
sample file and the AVISynth code is in this post.
Correcting hard-coded Wrong field Order
https://forum.videohelp.com/threads/418758-Is-it-worth-it-recapturing-videos/page3#post2781386
Sample file in post #71.
Dealing with WMVs
https://forum.videohelp.com/threads/419043-Avisynth-and-WMV-s-keeping-A-V-in-sync
Old 320x240 Digital Camera Video Files
Such small files, when expanded to normal size for editing, exhibit pronounced jaggies. They can be significantly
improved with AVISynth and VDub2. Here are some “before” and “after” shots:
This is the AVISynth code:
v=ffms2("file.MOV")
a=LWlibavAudioSource("file.MOV")
AudioDub(v,a)
ConvertToYV16()
Spline16Resize(400,300)
santiagmod(3,3) #reduce burned-in jaggies
QTGMC(inputtype=2) #repair badly deinterlaced video ie burned-in jaggies
converttoyv12()
lsfmod(strength=100,Smode = 3) #sharpen
Spline64Resize(768,576)
dehalo_alpha() #reduce halo effects on edges
#RIFE uses motion interpolation to increase framerate.
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f") # RIFE only works with RGB
floats
Rife(gpu_thread=1, model=11, fps_num=25000, fps_den=1000, sc=true, sc_threshold=0.12) # motion interpolate to 25
fps
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:f=>709:709:709:l") # back to YV12
VDub2 filters applied on the AVS file:
Camcorder Color Denoise (CCD); maximum strength
Sharpen: maximum strength
Here are the results on my Youtube channel:
https://www.youtube.com/watch?v=uU-qISwAJo8
Detecting Duplicated Frames
One of the bugbears of analogue video capture is dropped frames. Dropped frames themselves are hard to detect but
most digitisers will insert a duplicate frame (ie a copy of the previous frame) when a frame doesn’t appear at the correct
time. The duplicated frames count can then be used as a guide to the number of frames that have been dropped. The
DupMC function is very good at detecting duplicated frames.
DupMC uses VDub to produce a TXT file which shows the % difference between adjacent frames, thereby allowing
detection of duplicates ie 0% difference. Microsoft Excel can be used to tabulate the results as described below, or you
can simply search the TXT file for “0.0000” to find the duplicates.
DupMC only works with 8-bit so if you have a higher bit-depth video, you’ll need to convert it down to 8-bit.
AVISynth example script (also here as a download):
AVISource("H:\Videos\holiday1987.avi")
converttoyv12()
DupMC(log="H:\Videos\holiday1987.avi") #this is the text file that will be generated
1.
Open this script in VDub, then do a "File>Run video analysis pass" to generate a TXT data file.
2.
Close VDub.
3.
Open the text file in Excel (use "all file types" to reveal the TXT file). The Text Import Wizard will open.
4.
Step 1: Choose "Delimited" then Next
5.
Step 2: Untick "Tab". Tick "Other" and type in the = sign then Next
6.
Step 3: no changes, click Finish
7.
With the file open in Excel, delete the first line then select all.
8.
Data>Text to columns. At the warning, ignore it and click OK.
9.
Drag the A column edge to the right so you can see the full column info
10.
Sort on the seconds difference column (column B).
The duplicated frames will be those with Zero % difference. View them in VDub by opening the file, hit CTRL+G, then
type in the frame and hit Enter.
AVISynth Scenarios
Page Contents
•
Frame Interpolation with RIFE
•
Chroma Bleed in ANIME video
•
Removing Aliasing from Progressive video
(Jagged edging)
•
IVTC 3:2 Pulldown of MPEG2 in MKV
•
PSF Cleanup (VOB)
•
Anime aliasing and frame blending
•
Removing duplicates from a Bluray rip of an old
film
•
Correcting a 59.94 capture back to 29.97
•
Correcting hard-coded Wrong field Order
•
Dealing with WMVs
•
Old 320x240 Digital Camera Video Files
•
Detecting Duplicated Frames
Frame Interpolation with RIFE
Note: RIFE only operates on a 64bit system with the
latest graphic cards.
RIFE is a high-quality frame interpolation filter,
meaning it will smooth out videos by re/creating
frames that are missing, such as after duplicated or
blended frames have been removed by other filters,
for example when processing cine film that has been
captured by a video camera (telecine). It will
interpolate between two frames and create an in-
between frame. This results in smoother video.
The RIFE filter comprises two parts: the filter files
themselves, which are included in the plugins folder
in the above zip package, and the RIFE models,
which are a 1GB collection of files and folders which
detail the various models. I haven’t included the
models folder in the above download because of it’s
size; if you would like to use RIFE:
•
go to the Github RIFE page
•
click on the “Latest” button on the right
•
click on the link to the models to download the
zipped models folder.
Assuming you have set up AVISynth as I have
described above, the models folder needs to be
placed in the avisynth+\plugins64+ folder:
The actual model number to be used in the AVISynth
script is shown against the folder number is shown
lower down on the Github page linked-to above. For
example, folder 4.6 (True) is model number 24.
Note: only models using 4.1 and above will allow
adjustment/manual setting of the frame rate. Lower
models will only double the original framerate.
A typical RIFE script would look something like this,
with the user-variables in blue:
v=ffms2("H:\Magix Info\Jak\Deinterlaced
00059.m2ts")
a=LWLibavAudioSource("H:\Magix
Info\Jak\Deinterlaced 00059.m2ts")
AudioDub(v,a)
# RIFE only works with RGB floats
z_ConvertFormat(pixel_type="RGBPS",
colorspace_op="709:709:709:l=>rgb:709:709:f")
# motion interpolate to 50 fps
Rife(gpu_thread=1, model=11, fps_num=50000,
fps_den=1000, sc=true, sc_threshold=0.12)
# back to YV12
z_ConvertFormat(pixel_type="YUV420P8",
colorspace_op="rgb:709:709:f=>709:709:709:l")
RIFE Notes
•
If you find that RIFE is not interpolating during
rapid panning, try setting the “sc=” to false, or if a
scene change is in play, use sc1=True. Sc=True
leaves duplicates at the scene change. Sc1=True
blends the duplicate with the first frame of the
new scene.
Chroma Bleed in ANIME video
https://forum.videohelp.com/threads/416462-How-to-
remove-this-interlace-blending-chroma-bleed
Removing Aliasing from Progressive video
(Jagged edging)
https://forum.videohelp.com/threads/416435-Which-
copy-looks-better-to-you-Attachments#post2756412
VHS Capture of DVD restoration (file 2)
https://forum.videohelp.com/threads/416923-De-
Interlacing-another-DVD-from-collection
Another capture (file 1):
https://forum.videohelp.com/threads/416904-De-
Interlacing-DVD-and-changing-25FPS-To-24FPS
IVTC 3:2 Pulldown of MPEG2 in MKV
Ref: Davexnet
https://forum.videohelp.com/threads/404621-
MakeMKV/page2#post2762453
aud=ffaudiosource("D:\VH\Chris
Hooper\A1_t00.mkv",track=-1)
vid=ffvideosource("D:\VH\Chris
Hooper\A1_t00.mkv", track=-1,
seekmode=1,fpsnum=30000,fpsden=1001)
audiodub(vid,aud)
tfm().tdecimate()
Prefetch(24)
PSF Cleanup (VOB)
Ref Davexnet
v=ffms2("D:\VH\Akuma786\30Dec\VTS_01_1.VOB")
a=LWLibavAudioSource("D:\VH\Akuma786\30Dec\V
TS_01_1.VOB")
AudioDub(v,a)
qtgmc(inputtype=2,preset="medium")
crop(0,124,-0,-122)
depansafe(dxmax=4,dymax=4)
crop(2,6,-4,-8)
Anime aliasing and frame blending
https://forum.videohelp.com/threads/417775-
Difficult-low-quality-telecined-source
Removing duplicates from a Bluray rip of an
old film
https://forum.videohelp.com/threads/418061-
Solutions-for-a-film-with-duplicate-frames-without-
predictable-cycle#post2772415
Uses TDecimate(cycle=25,cycleR=3) to remove
dupes and return frame rate back to original of
22fps.
Correcting a 59.94 capture back to 29.97
https://forum.videohelp.com/threads/418065-
Converting-wrongly-captured-59-94fps-to-29-
97fps#post2772420
sample file and the AVISynth code is in this post.
Correcting hard-coded Wrong field Order
https://forum.videohelp.com/threads/418758-Is-it-
worth-it-recapturing-videos/page3#post2781386
Sample file in post #71.
Dealing with WMVs
https://forum.videohelp.com/threads/419043-
Avisynth-and-WMV-s-keeping-A-V-in-sync
Old 320x240 Digital Camera Video Files
Such small files, when expanded to normal size for
editing, exhibit pronounced jaggies. They can be
significantly improved with AVISynth and VDub2.
Here are some “before” and “after” shots:
This is the AVISynth code:
v=ffms2("file.MOV")
a=LWlibavAudioSource("file.MOV")
AudioDub(v,a)
ConvertToYV16()
Spline16Resize(400,300)
santiagmod(3,3) #reduce burned-in jaggies
QTGMC(inputtype=2) #repair badly deinterlaced
video ie burned-in jaggies
converttoyv12()
lsfmod(strength=100,Smode = 3) #sharpen
Spline64Resize(768,576)
dehalo_alpha() #reduce halo effects on edges
#RIFE uses motion interpolation to increase
framerate.
z_ConvertFormat(pixel_type="RGBPS",
colorspace_op="709:709:709:l=>rgb:709:709:f") #
RIFE only works with RGB floats
Rife(gpu_thread=1, model=11, fps_num=25000,
fps_den=1000, sc=true, sc_threshold=0.12) #
motion interpolate to 25 fps
z_ConvertFormat(pixel_type="YUV420P8",
colorspace_op="rgb:709:709:f=>709:709:709:l") #
back to YV12
VDub2 filters applied on the AVS file:
Camcorder Color Denoise (CCD); maximum
strength
Sharpen: maximum strength
Here are the results on my Youtube channel:
https://www.youtube.com/watch?v=uU-qISwAJo8
Detecting Duplicated Frames
One of the bugbears of analogue video capture is
dropped frames. Dropped frames themselves are
hard to detect but most digitisers will insert a
duplicate frame (ie a copy of the previous frame)
when a frame doesn’t appear at the correct time.
The duplicated frames count can then be used as a
guide to the number of frames that have been
dropped. The DupMC function is very good at
detecting duplicated frames.
DupMC uses VDub to produce a TXT file which
shows the % difference between adjacent frames,
thereby allowing detection of duplicates ie 0%
difference. Microsoft Excel can be used to tabulate
the results as described below, or you can simply
search the TXT file for “0.0000” to find the
duplicates.
DupMC only works with 8-bit so if you have a higher
bit-depth video, you’ll need to convert it down to 8-
bit.
AVISynth example script (also here as a download):
AVISource("H:\Videos\holiday1987.avi")
converttoyv12()
DupMC(log="H:\Videos\holiday1987.avi") #this is the
text file that will be generated
1.
Open this script in VDub, then do a "File>Run
video analysis pass" to generate a TXT data file.
2.
Close VDub.
3.
Open the text file in Excel (use "all file types" to
reveal the TXT file). The Text Import Wizard will
open.
4.
Step 1: Choose "Delimited" then Next
5.
Step 2: Untick "Tab". Tick "Other" and type in
the = sign then Next
6.
Step 3: no changes, click Finish
7.
With the file open in Excel, delete the first line
then select all.
8.
Data>Text to columns. At the warning, ignore it
and click OK.
9.
Drag the A column edge to the right so you can
see the full column info
10.
Sort on the seconds difference column (column
B).
The duplicated frames will be those with Zero %
difference. View them in VDub by opening the file,
hit CTRL+G, then type in the frame and hit Enter.