AVISynth Scenarios

Page Contents

• Frame Interpolation with RIFE • Change the Play Speed • 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

Change the Play Speed

To change the speed at which a video plays, use: AssumeFPS(XX) where the XX is the desired speed. For example, a digitised cine film might come out of processing as 16.67 frames per second, which is slightly slow. Use AssumeFPS(18) to make the video play/display at a speed of 18fps. This function shouldn’t be confused with “frames in a second”, which is what RIFE (and other frame interpolators and also double-rate deinterlacing) does to a video. They insert extra frames into that one seconds-worth of video so it becomes smoother but still plays at the same/correct speed.

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 capture program AmaRecTV produces a report, after capture, of the location of any duplicated frames. See here for details. The AVISynth DupMC function is very good at detecting duplicated frames. Thanks to @jagabo at VH for explaining this. 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 Open this script in VDub, then do a "File>Run video analysis pass" to generate report in a TXT data file. You can analyse the report, which measures frame differences either by: Searching the TXT file for 0.0000 to find the duplicated frames or Using Excel for a more user-friendly tabular display of the duplicated frames 1. Open the text file in Excel (use "all file types" to reveal the TXT file). The Text Import Wizard will open. 2. Step 1: Choose "Delimited" then Next 3. Step 2: Untick "Tab". Tick "Other" and type in the = sign then Next 4. Step 3: no changes, click Finish 5. With the file open in Excel, delete the first line then select all. 6. Data>Text to columns. At the warning, ignore it and click OK. 7. Drag the A column edge to the right so you can see the full column info 8. Sort on the seconds difference column (column B). The duplicated frames will be those with Zero % difference. View them in VDub by hitting CTRL+G, then type in the frame and hit Enter.
AVISynth Scenarios

Page Contents

• Frame Interpolation with RIFE • Change the Play Speed • 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

Change the Play Speed

To change the speed at which a video plays, use: AssumeFPS(XX) where the XX is the desired speed. For example, a digitised cine film might come out of processing as 16.67 frames per second, which is slightly slow. Use AssumeFPS(18) to make the video play/display at a speed of 18fps. This function shouldn’t be confused with “frames in a second”, which is what RIFE (and other frame interpolators and also double-rate deinterlacing) does to a video. They insert extra frames into that one seconds-worth of video so it becomes smoother but still plays at the same/correct speed.

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 capture program AmaRecTV produces a report, after capture, of the location of any duplicated frames. See here for details. The AVISynth DupMC function is very good at detecting duplicated frames. Thanks to @jagabo at VH for explaining this. 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 Open this script in VDub, then do a "File>Run video analysis pass" to generate report in a TXT data file. You can analyse the report, which measures frame differences either by: Searching the TXT file for 0.0000 to find the duplicated frames or Using Excel for a more user-friendly tabular display of the duplicated frames 1. Open the text file in Excel (use "all file types" to reveal the TXT file). The Text Import Wizard will open. 2. Step 1: Choose "Delimited" then Next 3. Step 2: Untick "Tab". Tick "Other" and type in the = sign then Next 4. Step 3: no changes, click Finish 5. With the file open in Excel, delete the first line then select all. 6. Data>Text to columns. At the warning, ignore it and click OK. 7. Drag the A column edge to the right so you can see the full column info 8. Sort on the seconds difference column (column B). The duplicated frames will be those with Zero % difference. View them in VDub by hitting CTRL+G, then type in the frame and hit Enter.