digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Edit Video, Audio (https://www.digitalfaq.com/forum/video-editing/)
-   -   Avisynth with Adobe Premiere, AVSInfoTools errors? (https://www.digitalfaq.com/forum/video-editing/12111-avisynth-adobe-premiere.html)

lollo2 12-20-2021 12:58 PM

I do not understand your script, and why you apply a lossless deinterlace if at the end you deinterlace for the final version, but maybe I am missing something.
In addition, a color matrix change should be done before upscaling.
I would experiment the following, reducing also the computation effort.

Code:

vidEdit = vidEdit.Crop(22,0, 0,0).AddBorders(10,0,12,0)y

AssumeBFF()

QTGMC( Preset="fast", EZKeepGrain=1.0, NoisePreset="Faster", NoiseProcess=0, FPSDivisor=2)
VInverse2() # if you see residual combing

# --> select here the segments where following filtering should be applied
FAN(lambda=5, plus=1, minus=50)
FAN(lambda=5, plus=50, minus=1)

ChromaShift(C=6, L=2)

SpotLess(RadT=3, ThSAD=1000, Blksz=16).SpotLess(RadT=5, ThSAD=300, Blksz=16).RemoveDirtSMC(20)

FixChromaBleedingMod(thr=7, strength=0.8)

MergeChroma(aWarpSharp2(thresh=200,depth=30, type=1,blur=4, chroma=3).aWarpSharp2(thresh=200,depth=30, type=1,blur=4,chroma=3))
TurnRight()
MergeChroma(aWarpSharp2(thresh=200,depth=30,type=1,blur=4).aWarpSharp2(thresh=200,depth=30,type=1,blur=4))
TurnLeft()

SmoothUV(radius=2, field=false)

# --> merge the filtered segments with the rest

ColorMatrix(mode="Rec.601->Rec.709")

nnedi3_rpow2(4, cshift="Spline36Resize", fwidth=1920, fheight=1440)

LSFmod(strength=100, preblur="ON")
AddGrainC(var=2)

# as alternative experiment if LSFMod before upscaling gives a better result

You can solve the "memory" problem by splitting the operations in 2 steps, generating an intermediate file (unfortunatly, the disk occupation will be twice while processing).

Quote:

Is there a way around this besides raising the black level before the filter?
The denoise and QTGMC processing probably changes your (whatever) input levels to output levels 0-255. You can use Levels() functions before changing the color matrix to adapt them at your own taste. Better to use a Levels() version which only acts on Luma and leaves Chroma unaffected.

Winsordawson 12-21-2021 08:46 PM

3 Attachment(s)
Sorry--I left that de-interlacer there because if I did not divide by two with QTGMC in the beginning, all of my frames that I trimmed later on would be screwed up, so I want to fix that issue first.

It seems that there is a slight color banding on the bottom of each other frame if I don't choose FPSDivisor=2. I would obviously rather keep the 59.97, but I do not know what is the problem. Below I have attached two consecutive frames to show the difference, with another picture highlighting the extra banding. Is this common?

Attachment 14436

Attachment 14437

Attachment 14438

Also, you were right about the resizer and QTGMC affecting the color. I didn't know this could happen. ColorMatrix brought the colors into 16-235 territory but the nnedi3 resizer brought them back out of the safe zone. I guess I will have to apply another ColorYUV() at the end. I am surprised that is not more documented.

Lastly, do you think my issue in VirtualDub was because my script was too intensive (despite having 16gb of RAM)? Was my resize correct? I have read that if the resize is not done correctly VirtualDub could throw an error, but 1920 by 1440 is 4:3 and mod-2, so I don't know what else could be the issue.

If it is simply a RAM issue then I won't have a problem resizing in a second script--I just want to make sure that I am not doing something else wrong. I am using only 32-bit Avisynth, so that can't help, either.

Thank you again for all your help--I'll make sure to not bother you until after the holiday!:laugh:

lollo2 12-22-2021 04:27 AM

Quote:

Below I have attached two consecutive frames to show the difference, with another picture highlighting the extra banding. Is this common?
Not really. Try to play with QTGMC parameters and to crop before QTGMC. I always do that.
same frame-rate QTGMC is not a good idea, except if no motion is present. Some details here: http://www.digitalfaq.com/forum/vide...mc-script.html

Quote:

I will have to apply another ColorYUV() at the end
Difficult to be accurate with ColorYUV. Better use a Levels() function acting only on Luma:
Code:

function LevelsLumaOnly(clip c,
\                      int input_low, float gamma, int input_high,
\                      int output_low, int output_high)
{
    return MergeChroma(c.Levels(input_low, gamma, input_high,
    \                          output_low, output_high),
    \                  c)
}

Quote:

Was my resize correct?
No. Analog video once captured in SD is 720x576 (or 720x480) at 4:3 DAR. Upscaling to HD the height is 1080, then the width must be 1040x4/3 = 1440.
You then leave the frame at 1440x1080 or you add 240 black borders on each side to build the standard fullHD frame size.

Quote:

I'll make sure to not bother you until after the holiday!
Don't worry, I am learning as well. Each video is unique and has its specific issues, so is rare that a standard processing is applied. Looking different samples is always instructive ;-)

lollo2 12-22-2021 05:39 AM

Quote:

then the width must be 1040x4/3 = 1440.
then the width must be 1080x4/3 = 1440 (typo correction)

Winsordawson 12-22-2021 11:06 AM

Thank you again. Just to clarify something (before your break!), isn't 1440x1080 only 4:3 with 1:1 (square) pixels and this SD video (in NTSC land of 720x480) is based off non-square pixels?

From what I read, 720x480p is 4:3 DAR but 10:11 PAR and an aspect ratio of 3:2 (1.5). My 1920x1080 is wrong because that is 16:9, so I should upscale to another 3:2 format, like 2160 x 1440, no?

I would rather not crop the 720x480, and the only purpose of this deinterlaced version is for YT to get a better bitrate. Since 2160x 1440 is not an acceptable format, they will add pillarboxes to it, but I am okay with that.

Feel free to suggest any reading material if you know a good source. This area is a bit confusing. :blink:

P.S. I did crop before QTGMC but I will play with the settings like ChromaMotion

lollo2 12-23-2021 04:20 AM

I generally use this semplified approach for PAL:

720x576 SD, DAR (display aspect ratio)=4:3, SAR (storage aspect ratio)=720/576=5/4, PAR (pixel aspect ratio)=DAR/SAR=4/3*4/5=16/15
non square pixel, because PAR is not 1

in your NTSC land will be:

720x480 SD, DAR (display aspect ratio)=4:3, SAR (storage aspect ratio)=720/480=3/2, PAR (pixel aspect ratio)=DAR/SAR=4/3*2/3=8/9
non square pixel, because PAR is not 1

convert to HD:
1- height of HD = 1080
2- width of HD = height of HD * DAR SD = 1080 * 4/3 = 1440

1440x1080 HD, DAR (display aspect ratio)=4:3, SAR (storage aspect ratio)=1440/1080=4/3, PAR (pixel aspect ratio)=DAR/SAR=4/3*3/4=1
square pixel, because PAR= 1

To be more accurate, it should be considered the ITU-R BT.601-4 (formerly "CCIR-601" or "Rec.601") spefication for Analog SD is 702(704)x480 pixel inside the 720x480 frame, the rest should be black.
So you can crop to 702(704)x480 before upscaling.

Some references:

http://www.arachnotron.nl/videocap/d..._cap_v1_en.pdf

http://web.archive.org/web/200606211...eo/conversion/

lollo2 12-23-2021 05:31 AM

If you prefere to build the fullHD frame:

convert to HD:
1- height of HD = 1080
2- width of HD = height of HD * DAR SD = 1080 * 4/3 = 1440
3- add 240 black pixels on the left and on the right --> 1920x1080

1920x1080 HD, DAR (display aspect ratio)=16:9, SAR (storage aspect ratio)=1920/1080=16/9, PAR (pixel aspect ratio)=DAR/SAR=16/9*9/16=1
square pixel, because PAR=1

Winsordawson 01-01-2022 01:54 PM

Thank you for the explanation. I hope you are having a good start to the new year. I have tried to read up on this area but it still seems too complicated for me. But my understanding is that when we upscale, the PAR must be 1:1 square pixel because that is the only PAR for computers, right? A Doom9 poster wrote ""Converting to square pixels" is just another word for resize."

In that case, I could also do 1920 x 1440?
Height of 1440p HD = 1440
Width = 1440 x DAR SD = 1440 * 4/3 = 1920.

The SAR is 1920/1440 = 4/3. If we intend for it to be shown on a 4:3 screen, DAR =4/3, correct? So (4/3)/(4/3) = 1 PAR.

If I am right, you upload your videos on YT as 1440 x 1080 and not 1920 x 1440, and I do see a quality difference over SD. Would it be worth upscaling to 1440p 4:3 or 1080p 4:3 should be fine?

On another note, I am a bit confused about converting to square pixels that is on Lurkertech's guide. It says at the below link that the 480i signal NTSC signal starts at 720x486 and we can convert this to 640x486 square pixels. But if we upscale to 1440x1080 without first converting to 640x486, we are basing it off the 720x480 (minus the 6 lines lost in overscan). What would be the difference if we first converted to 640x480 and then to 1440x1080?

https://lurkertech.com/lg/pixelaspect/

And, if I wish to keep an interlaced version as well of the original 720x480 video, I would prefer to save it as AVI or MPEG-2. From what I have read, AVIs always display in 1:1 PAR, so if I save the 720x480 video will it be distorted since it uses a PAR of 8/9.

Using your formula above, is this correct:

I would rather add letterbox than crop the image and remove data. We know the PAR we want (1:1) and the DAR (4/3). This, SAR = DAR/PAR = (4/3)/(1/1) = 1.33333. If the width is 720 does that mean to keep it as 4:3 I must have a height of 540? 720/540 = 1.333 :question:

But I can't resize interlaced video, so I would first have to de-interlace it with something like needi3, resize, and then re-interlace?:unsure:

If I have been doing it wrong previously, why have I never seen any distortions when playing 720x480i AVIs on my computer, if AVIs don't support a DAR?
https://forum.videohelp.com/threads/...nd-Resolutions

lollo2 01-01-2022 03:08 PM

1440 is not a HD or fullHD vertical resolution, which is 1080

You can set horizontal resolution to 1920 (fullHD) with DAR 16:9 or 1440 (HD) with DAR 4:3. Starting from SD frame, if you want the first, you preliminary generate the 1440x1080 frame and then add 240 black borders on each side.

Quote:

What would be the difference if we first converted to 640x480 and then to 1440x1080?
Why do you want to resize several times? Each processing can be lossy (we only do when we want to sharpen a bit between intermediate steps). And why do you want to convert between square and not square pixels? Any PC player or modern TV handle DAR info whatever the PAR is.

Quote:

From what I have read, AVIs always display in 1:1 PAR
An avi container for analog captures does not contain the DAR info or flag. You must set your player (i.e. in VLC -> Video -> Aspect Ratio -> 4:3, or add the flag manually with ffmpeg or add the apsct ratio while encoding. We were just discussing it: http://www.digitalfaq.com/forum/vide...s-capture.html

lollo2 01-01-2022 04:54 PM

Quote:

I hope you are having a good start to the new year.
I wish the same, all the best to you and to the other users for 2022!!!

Winsordawson 03-24-2023 05:06 PM

Sorry to resurrect this thread, but I finally had time to get back to this query (after going crazy for a few days). It seems that there are some issues with VirtualDub when I run this script. I am unable to run the x264vfw codec on this file in VirtualDub1 or VirtualDub2 (both 32-bit, because of all the different plugins) without getting the error "Video compression error: An unknown error occurred (may be corrupt data). (error code -100)"

When I try to encode it with FFV1 8-bit 4:2:0 I get the error "Video compression error: Not enough memory. (error code -3)". I realize that this might be due to using 32-bit due to the 4gb limitation, but is there a way to still process the video more slowly without going over the limit?

For some reason, the encoding works fine in FFMPEG x265 and x265 lossless.



Here is the code I have been using

Code:

video1 = FFmpegSource2(source="video.avi",atrack=-1).AssumeBFF
#video1 = AVISource("video.avi").AssumeBFF
audio1 = video1
last = video1

#replaces dropouts
ReplaceFramesMC2(192, 1)
ReplaceFramesMC2(194, 5)
ReplaceFramesMC2(268, 2)
ReplaceFramesMC2(315, 8)
ReplaceFramesMC2(359, 3)
ReplaceFramesMC2(500, 4)
ReplaceFramesMC2(520, 5)
ReplaceFramesMC2(5619, 1)

video2 = AudioDub(last, audio1)


#removes title segments because they should not have filters applied to them
seg1 = video2.Trim(3955,4093)
seg2 = video2.Trim(6264,6412)
seg3 = video2.Trim(10052,10200)
seg4 = video2.Trim(13981,14129)
seg5 = video2.Trim(17598,17746)
seg6 = video2.Trim(21230,21359)

#creates video without title sequences to now start filtering
vidEdit = video2.Trim(0, 3944) + video2.Trim(4094, 6263) + video2.Trim(6413, 10051) + video2.Trim(10201, 13980) + video2.Trim(14130,17597) + video2.Trim(17747,21230)

vidEdit = vidEdit.Crop(22,0, 0,0).AddBorders(10,0,12,0)

/*Double-checking correct width*/
# return Subtitle(last, String(vidEdit.Width), size = 32) 
last = vidEdit

#deinterlaces better than separatefields
AssumeBFF().nnedi3(field=-2)

#removes vertical banding noise, shifts chroma, and then removes dropouts
FAN(lambda=5, plus=1, minus=50)
FAN(lambda=5, plus=50, minus=1)
ChromaShift(C=4, L=2)
SpotLess(RadT=3, ThSAD=1000, Blksz=16).SpotLess(RadT=5, ThSAD=300, Blksz=16).RemoveDirtSMC(20)
#THIS DOES NOT WORK AS WELL-->TemporalDegrain2(degrainTR=3)

FixChromaBleedingMod(thr=7, strength=0.8)

MergeChroma(aWarpSharp2(thresh=200,depth=30, type=1,blur=4, chroma=3).aWarpSharp2(thresh=200,depth=30, type=1,blur=4,chroma=3))
TurnRight()
MergeChroma(aWarpSharp2(thresh=200,depth=30,type=1,blur=4).aWarpSharp2(thresh=200,depth=30,type=1,blur=4))
TurnLeft()

SmoothUV(radius=2, field=false)

#puts interlace image back together
AssumeBFF().SeparateFields().SelectEvery(4,0,3).Weave()

vidEditFinal = last

vidFinal = vidEditFinal.Trim(0, 3944) + seg1 + vidEditFinal.Trim(3945, 6113) +seg2 + vidEditFinal.Trim(6114, 9756) +seg3 + \
vidEditFinal.Trim(9757, 13529) + seg4 + vidEditFinal.Trim(13530, 17001) + seg5 + vidEditFinal.Trim(17002, 0) + seg6

#test sample
last = vidFinal.Trim(1800, 2300)


QTGMC( Preset="fast", EZKeepGrain=1.0, NoisePreset="Faster", NoiseProcess=0)
VInverse2()

nnedi3_rpow2(4, cshift="Spline36Resize", fwidth=1440, fheight=1080)

LSFmod(strength=150, preblur="ON")
AddGrainC(var=10)

#For upscaling to high definition for YT
ColorMatrix(mode="Rec.601->Rec.709", interlaced=false)

return last

Thanks for any suggestions.

lollo2 03-24-2023 05:28 PM

I ignore why VirtualDub and VirtualDub2 have problems, but for a basic x264 compression they are useless and you do not need at all.
Just run a simply ffmpeg command line instead, as you apparently do for x265:

Code:

ffmpeg.exe -i <input>.avs -c:v libx264 -crf 17 -preset slow -aspect 4:3 -c:a aac -b:a 128k <output>.mp4

Winsordawson 03-24-2023 06:23 PM

Quote:

Originally Posted by lollo2 (Post 89774)
I ignore why VirtualDub and VirtualDub2 have problems, but for a basic x264 compression they are useless and you do not need at all.
Just run a simply ffmpeg command line instead, as you apparently do for x265:

Code:

ffmpeg.exe -i <input>.avs -c:v libx264 -crf 17 -preset slow -aspect 4:3 -c:a aac -b:a 128k <output>.mp4

Thanks for the quick reply--it is always appreciated. While I would have no issue exporting FFV1 or x264 or x265 in FFMPEG (since I am not using VD filters), when I try to run a command like the one you wrote, it says Unknown error occurred. It seems there is some issue with opening .avs files (opening non-avs files works).

I spent about 10 hours straight trying to figure out the FFMPEG problem before posting. From what I read, I had to install Avisynth headers from the source code, build just the headers, then make and install avisynth.h under an include folder where FFMPEG is installed (which I added). I finally was able to do that after asking ChatGPT for instructions :o. While it was a success, the error didn't go away. When I try to pipe it through avs2yuv it actually works but the quality does not look that good.

Any ideas?

lollo2 03-25-2023 04:21 AM

Quote:

From what I read, I had to install Avisynth headers from the source code, build just the headers, then make and install avisynth.h under an include folder where FFMPEG is installed (which I added).
No idea of what you are talking about, sorry.

Just install AviSynth as usual (I suppose VirtualDub was able to read and display your AviSynth script, so this should be ok), and place downloaded FFMpeg binary somewhere, no need to install anything here.

Upload a portion of your source (we already have the AviSynth script), so we can try to reproduce your problem.

Winsordawson 03-26-2023 10:10 AM

1 Attachment(s)
Thank you, but this problem occurs even though Avisynth+ and FFMPEG are already installed (I used it to make this segment from the complete .avi, so it would seem that the issue is not with FFMPEG. It just cannot open avs files. Should I reinstall Avisynth+? I have attached a segment.

lollo2 03-26-2023 10:26 AM

I tried your script on your old video (not the right source, but just to try all the filters you use; all trims removed) and it works fine here when feeding a ffmpeg command line as above.

If you experience "Unknown error occurred" it may be related to ffmpeg not finding some of the plugins. Try to specify an absolute path instead of a relative path in your avs script.

My (working) script attached as reference (change the path with yours):

Code:

# plugins directory
plugins_dir="C:\Users\giuse\Documents\VideoSoft\MPEG\AviSynth\extFilters\"

        # FFmpegSource
loadPlugin(plugins_dir + "ffms2_87bae19\x86\ffms2.dll")

        # ReplaceFramesMC2
import(plugins_dir + "ReplaceFramesMC2.avsi")

        # MVTools
loadPlugin(plugins_dir + "mvtools-2.7.41-with-depans20200430\x86\mvtools2.dll")

        # Nnedi3
loadPlugin(plugins_dir + "NNEDI3_v0_9_4_55\x86\Release_W7\nnedi3.dll")

        # FanFilter
loadPlugin("C:\Users\giuse\Desktop\tmp\FanFilter\FanFilter.dll")

        # ChromaShift
loadPlugin(plugins_dir + "chromashift27\ChromaShift.dll")

        # SpotLess
import(plugins_dir + "SpotLess.avsi")

        # MedianBlur2
loadPlugin(plugins_dir + "MedianBlur2_v1.1\x86\MedianBlur2.dll")

        # SpotLess
import(plugins_dir + "SpotLess.avsi")

        # RemoveDirt2_modGMa
import(plugins_dir + "RemoveDirt2_modGMa.avsi")

        # RgTools
loadPlugin(plugins_dir + "RgTools-v1.0\x86\RgTools.dll")

        # RemoveDirt
loadPlugin("C:\Users\giuse\Desktop\tmp\RemoveDirt-0.9.3\x86\RemoveDirt.dll")

        # SeeSaw
import(plugins_dir + "SeeSaw.avs")

        # MaskTools2
loadPlugin(plugins_dir + "masktools2-v2.2.23\x86\masktools2.dll")

        # FixChromaBleedingMod.avsi
import("C:\Users\giuse\Desktop\tmp\FixChromaBleedingMod.avsi")

        # Zs_RF_Shared
Import("C:\Users\giuse\Desktop\tmp\Zs_RF_Shared.avsi")

        # ChromaShiftSP
import("C:\Users\giuse\Desktop\tmp\ChromaShiftSP.avsi")

        # aWarpSharp
loadPlugin(plugins_dir + "aWarpSharpMT_v2_1_3\x86\Release_W7\aWarpsharpMT.dll")

        # SmoothUV
loadPlugin(plugins_dir + "smoothuv_5F25_dll_20030902\SmoothUV.dll")

        # QTGMC
Import(plugins_dir + "QTGMC.avsi")

        # vinverse
loadPlugin(plugins_dir + "vinverse-x86\vinverse.dll")

        # LSFmod
Import(plugins_dir + "LSFmod.v1.9.avsi")

        # AddGrainC
loadPlugin(plugins_dir + "AddGrainC-v1.8.2\clang\x86\AddGrainC.dll")

        # ColorMatrix
LoadPlugin(plugins_dir + "ColorMatrix\ColorMatrix.dll")

video1 = FFmpegSource2(source="intrepretative dance before.avi",atrack=-1).AssumeBFF
#video1 = AVISource("video.avi").AssumeBFF
audio1 = video1
last = video1

#replaces dropouts
ReplaceFramesMC2(192, 1)
ReplaceFramesMC2(194, 5)
ReplaceFramesMC2(268, 2)
ReplaceFramesMC2(315, 8)
ReplaceFramesMC2(359, 3)
ReplaceFramesMC2(500, 4)
ReplaceFramesMC2(520, 5)
ReplaceFramesMC2(5619, 1)

video2 = AudioDub(last, audio1)


#removes title segments because they should not have filters applied to them
seg1 = video2.Trim(3955,4093)
seg2 = video2.Trim(6264,6412)
seg3 = video2.Trim(10052,10200)
seg4 = video2.Trim(13981,14129)
seg5 = video2.Trim(17598,17746)
seg6 = video2.Trim(21230,21359)

#creates video without title sequences to now start filtering
vidEdit = video2 #.Trim(0, 3944) + video2.Trim(4094, 6263) + video2.Trim(6413, 10051) + video2.Trim(10201, 13980) + video2.Trim(14130,17597) + video2.Trim(17747,21230)

vidEdit = vidEdit.Crop(22,0, 0,0).AddBorders(10,0,12,0)

/*Double-checking correct width*/
# return Subtitle(last, String(vidEdit.Width), size = 32) 
last = vidEdit

#deinterlaces better than separatefields
AssumeBFF().nnedi3(field=-2)

#removes vertical banding noise, shifts chroma, and then removes dropouts
FAN(lambda=5, plus=1, minus=50)
FAN(lambda=5, plus=50, minus=1)
ChromaShift(C=4, L=2)
SpotLess(RadT=3, ThSAD=1000, Blksz=16).SpotLess(RadT=5, ThSAD=300, Blksz=16).RemoveDirtSMC(20)
#THIS DOES NOT WORK AS WELL-->TemporalDegrain2(degrainTR=3)

FixChromaBleedingMod(thr=7, strength=0.8)

MergeChroma(aWarpSharp2(thresh=200,depth=30, type=1,blur=4, chroma=3).aWarpSharp2(thresh=200,depth=30, type=1,blur=4,chroma=3))
TurnRight()
MergeChroma(aWarpSharp2(thresh=200,depth=30,type=1,blur=4).aWarpSharp2(thresh=200,depth=30,type=1,blur=4))
TurnLeft()

SmoothUV(radius=2, field=false)

#puts interlace image back together
AssumeBFF().SeparateFields().SelectEvery(4,0,3).Weave()

vidEditFinal = last

vidFinal = vidEditFinal #.Trim(0, 3944) + seg1 + vidEditFinal.Trim(3945, 6113) +seg2 + vidEditFinal.Trim(6114, 9756) +seg3 + \
vidEditFinal.Trim(9757, 13529) + seg4 + vidEditFinal.Trim(13530, 17001) + seg5 + vidEditFinal.Trim(17002, 0) + seg6

#test sample
last = vidFinal #.Trim(1800, 2300)


QTGMC( Preset="fast", EZKeepGrain=1.0, NoisePreset="Faster", NoiseProcess=0)
VInverse2()

nnedi3_rpow2(4, cshift="Spline36Resize", fwidth=1440, fheight=1080)

LSFmod(strength=150, preblur="ON")
AddGrainC(var=10)

#For upscaling to high definition for YT
ColorMatrix(mode="Rec.601->Rec.709", interlaced=false)

return last.trim(0,200)


Winsordawson 03-26-2023 01:04 PM

Thanks for the tip. Sadly, I still get the same Unknown error occurred. This is my script:

Code:

#plugins directory
plugins_dir = "C:\Program Files (x86)\AviSynth+\plugins+\"

#FFmpegSource
LoadPlugin(plugins_dir + "ffms2.dll")

#ReplaceFramesMC2
Import(plugins_dir + "ReplaceFramesMC2.avsi")

#MVTools
loadPlugin(plugins_dir + "mvtools2.dll")

# Nnedi3
loadPlugin(plugins_dir + "nnedi3.dll")

# FanFilter
loadPlugin(plugins_dir + "FanFilter.dll")

# ChromaShift
loadPlugin(plugins_dir + "ChromaShift.dll")

# SpotLess
import(plugins_dir + "SpotLess.avsi")

# MedianBlur2
loadPlugin(plugins_dir + "MedianBlur2.dll")

# RemoveDirt
loadPlugin(plugins_dir + "RemoveDirt.dll")

# RemoveDirt2SMC
import(plugins_dir + "RemoveDirtSMC.avsi")

# RgTools
loadPlugin(plugins_dir + "RgTools.dll")

# MaskTools2
loadPlugin(plugins_dir + "masktools2.dll")

# FixChromaBleedingMod.avsi
Import(plugins_dir + "FixChromaBleedingMod.avsi")

# Zs_RF_Shared
Import(plugins_dir + "Zs_RF_Shared.avsi")

# ChromaShiftSP
Import(plugins_dir + "ChromaShiftSP.avsi")

# aWarpSharp
loadPlugin(plugins_dir + "aWarpsharpMT.dll")

# SmoothUV
loadPlugin(plugins_dir + "SmoothUV.dll")

# QTGMC
Import(plugins_dir + "QTGMC.avsi")

# vinverse
loadPlugin(plugins_dir + "vinverse.dll")

# LSFmod
Import(plugins_dir + "LSFmod.v1.9.avsi")

# AddGrainC
loadPlugin(plugins_dir + "AddGrainC.dll")

# ColorMatrix
LoadPlugin(plugins_dir + "ColorMatrix32.dll")

video1 = FFmpegSource2(source="C:\Users\admin\Documents\video.avi",atrack=-1).AssumeBFF
audio1 = video1
last = video1

#replaces dropouts
ReplaceFramesMC2(192, 1)
ReplaceFramesMC2(194, 5)
ReplaceFramesMC2(268, 2)
ReplaceFramesMC2(315, 8)
ReplaceFramesMC2(359, 3)
ReplaceFramesMC2(500, 4)
ReplaceFramesMC2(520, 5)
ReplaceFramesMC2(5619, 1)

video2 = AudioDub(last, audio1)

#removes title segments because they should not have filters appiled to them
seg1 = video2.Trim(3955,4093)
seg2 = video2.Trim(6264,6412)
seg3 = video2.Trim(10052,10200)
seg4 = video2.Trim(13981,14129)
seg5 = video2.Trim(17598,17746)
seg6 = video2.Trim(21230,21359)

#creates video without title sequences to now start filtering
vidEdit = video2.Trim(0, 3944) + video2.Trim(4094, 6263) + video2.Trim(6413, 10051) + video2.Trim(10201, 13980) + video2.Trim(14130,17597) + video2.Trim(17747,21230)

vidEdit = vidEdit.Crop(22,0, 0,0).AddBorders(10,0,12,0)

/*Double-checking correct width*/
# return Subtitle(last, String(vidEdit.Width), size = 32) 
last = vidEdit

#deinterlaces better than separatefields
AssumeBFF().nnedi3(field=-2)

#removes vertical banding noise, shifts chroma, and then removes dropouts
FAN(lambda=5, plus=1, minus=50)
FAN(lambda=5, plus=50, minus=1)
ChromaShift(C=4, L=2)
SpotLess(RadT=3, ThSAD=1000, Blksz=16).SpotLess(RadT=5, ThSAD=300, Blksz=16).RemoveDirtSMC(20)
#THIS DOES NOT WORK AS WELL-->TemporalDegrain2(degrainTR=3)


FixChromaBleedingMod(thr=7, strength=0.8)

MergeChroma(aWarpSharp2(thresh=200,depth=30, type=1,blur=4, chroma=3).aWarpSharp2(thresh=200,depth=30, type=1,blur=4,chroma=3))
TurnRight()
MergeChroma(aWarpSharp2(thresh=200,depth=30,type=1,blur=4).aWarpSharp2(thresh=200,depth=30,type=1,blur=4))
TurnLeft()

SmoothUV(radius=2, field=false)

#puts interlace image back together
AssumeBFF().SeparateFields().SelectEvery(4,0,3).Weave()

vidEditFinal = last

vidFinal = vidEditFinal.Trim(0, 3944) + seg1 + vidEditFinal.Trim(3945, 6113) +seg2 + vidEditFinal.Trim(6114, 9756) +seg3 + \
vidEditFinal.Trim(9757, 13529) + seg4 + vidEditFinal.Trim(13530, 17001) + seg5 + vidEditFinal.Trim(17002, 0) + seg6

last = vidFinal.Trim(1800, 2300)

QTGMC( Preset="fast", EZKeepGrain=1.0, NoisePreset="Faster", NoiseProcess=0)
VInverse2()

nnedi3_rpow2(4, cshift="Spline36Resize", fwidth=1440, fheight=1080)

LSFmod(strength=150, preblur="ON")
#add only luma noise, not color as that is more noticable
AddGrainC(var=10)

#For upscaling to high definition for YT
ColorMatrix(mode="Rec.601->Rec.709", interlaced=false)

#colorYUV(analyze=true)
#Histogram("levels")

return last

Maybe it has something to do with the errors I get when opening Avisynth+? Every time I open a script I get something like this, which I read may have to do with Registry order of reading the plugins:

Code:

Error parsing WriteFileEnd plugin parameters: + without preceeding argument
Error parsing WriteFile plugin parameters: unknown character 'n'
Error parsing WriteFile plugin parameters: + without preceeding argument
Error parsing WriteFileIf plugin parameters: unknown character 'n'
Error parsing WriteFileIf plugin parameters: + without preceeding argument
Error parsing WriteFileStart plugin parameters: unknown character 'n'
Error parsing WriteFileStart plugin parameters: + without preceeding argument
Error parsing WriteFileEnd plugin parameters: unknown character 'n'
Error parsing WriteFileEnd plugin parameters: + without preceeding argument
Error parsing propSetInt plugin parameters: unknown character 'n'
Error parsing propSetFloat plugin parameters: unknown character 'n'
Error parsing propSetString plugin parameters: unknown character 'n'
Error parsing propSetArray plugin parameters: unknown character 'n'
Error parsing propSetClip plugin parameters: unknown character 'n'
Error parsing OnCPU plugin parameters: unknown character 'n'
Error parsing OnCUDA plugin parameters: unknown character 'n'
Error parsing OnCPU plugin parameters: unknown character 'n'
Error parsing OnCUDA plugin parameters: unknown character 'n'

I am using x32 version.

lollo2 03-26-2023 01:35 PM

I do not know, sorry, I do not use AviSynth+.

Maybe you can try first with AviSynth, and then if everything works switch to AviSynth+ debugging step by step (one filter at the time)

Winsordawson 03-26-2023 03:24 PM

Do you think it matters if it does not open any .avs file, regardless of the filters? I tried it on the authors.avs file that comes with Avisynth and the same error occurs.

I also see that my FFMPEG is 64 bit while I have installed only 32bit Avisynth+. Could that be an issue?

lollo2 03-26-2023 04:11 PM

Quote:

Do you think it matters if it does not open any .avs file, regardless of the filters? I tried it on the authors.avs file that comes with Avisynth and the same error occurs.
It does matter. It's not normal.

Quote:

I also see that my FFMPEG is 64 bit while I have installed only 32bit Avisynth+. Could that be an issue?
Probably yes. Be consistent with 32bit / 64 bit versions

Winsordawson 04-01-2023 05:43 PM

5 Attachment(s)
It took some time to install 64-bit Avisynth+ and change all of the filters, but now everything is working, so thank you for the help!

I am trying to archive a version of the restored video but FFV1 takes up too much space. I have read that mpeg2 is a good codec for analog from experts like Lordsmurf, so I exported clips at 10, 20, and 30 MBs. It is hard to tell when the video is playing but when paused the effect is noticeable, mainly in how the grain is preserved, which I want.

FFV1 Lossless
Attachment 16356

mpeg2 20 Mbps
Attachment 16357

mpeg2 30 Mbps
Attachment 16358

To me, there is a significant improvement in the grain preserved between the 20mbps and 30mbps mpeg2 video, but it still doesn't match the FFV1. Do you think going to 40Mbps is extreme or is there a better codec that can preserve this grain while not exploding the file size? I have no problem taking time in the encoding stage, since this is for archiving (I will still keep the original .avi).

I should note that, while the grain is artificial, it helps to give the psychological effect of more detail, which is why I add luma noise at the end.

P.S. For some reason the FFV1 lossless inline attachment is not coming out right, so I have attached it as well. I uploaded a .png but for some reason it is being automatically converted to .jpg, so the grain is blurred. The easiest place to see a difference (at least on my PC) is on his left cheek.

P.S. P.S. Imgur was able to preserve the grain detail:
https://i.imgur.com/fa2oS4r.png

lollo2 04-02-2023 10:35 AM

There is not a single reason today to archive in obsolete MPEG2 format. Nowdays is only used for DVD. Broadcasted TV switched to AVC codec since longtime for good reasons, even for SD interlaced material. Same for Blue Ray.

The preferred choice for archival is the original capture, large HD drives are not expensive today.

If you really want to compress your captures use h264 at low crf, slow preset, YUV 4:2:2 and interlaced options if required. Someting like:

Code:

ffmpeg.exe -i <input file> -c:v libx264 -crf 17 -preset slow -aspect 4:3 -x264opts interlaced:tff=1 -c:a aac -b:a 128k <output>.mp4

Winsordawson 04-02-2023 12:01 PM

Thank you. From what I have read on this site, H.264 does not handle interlaced well, so MPEG2 should be used instead because it was designed with analog formats in mind. Is this your view?

For progressive formats, what bitrate would you suggest is archival quality for a typical deinterlaced 1080p video? 15mbps? I know there are calculators out there, but I care more about the quality than determining file size.

lollo2 04-02-2023 12:51 PM

Quote:

I have read on this site, H.264 does not handle interlaced well, so MPEG2 should be used instead because it was designed with analog formats in mind. Is this your view?
What you read is false; there were some (useless) GUIs like Handbrake or similar having problems 10 years ago, but not the codec. And no, it is not my view.

https://forum.videohelp.com/threads/...H-264-encoding

Quote:

For progressive formats, what bitrate would you suggest is archival quality for a typical deinterlaced 1080p video? 15mbps? I know there are calculators out there, but I care more about the quality than determining file size.
Use crf, a parameter for determining quality rather than calculate bitrate and then final size. :wink2:

If you search the forum there should be a comparison I made between a huffyuv capture and its h264 encoding at low crf. Not really distinguishable at normal view, need a 4x magnification to find artifacts. And you can repeat the experiment by yourself on your own material.

Winsordawson 04-02-2023 02:15 PM

Thanks--it turns out that FFMPEG has an option with libx264 called -tune grain, which can preserve the grain in video. At crf 17, the file size is about 30% that of FFV1.

I don't know much about MPEG-2 vs h.264 debate for analog, but why do you think LordSmurf recommended the former is this post, if you say MPEG-2 is obsolete: https://www.digitalfaq.com/forum/vid...html#post38025
Quote:

I archive my own VHS home movies as 15mbps Blu-ray spec SD 720x480 MPEG-2. They look great. A version can be saved to hard drive, and a disc can be burned for myself and family member. At least one member also has me load them on hard drive, too.

Only when a video needs restoration, do I capture to Huffyuv. It's processed, then converted to 15mpbs MPEG when done.

lollo2 04-02-2023 03:06 PM

No idea. Better ask him directly.

I disagree with him more than I agree on many points, but he's a resource for the community, that's for sure.

I would never capture to MPEG2, even if no restoration is needed.

But all this is not really important, what is important is that you found your way of capturing and restoring your video with good quality, and did significant progress since you started.

Good luck with your captures/restoration!

Winsordawson 04-02-2023 03:28 PM

Yes, in part due to your help. Thank you for all of the tips along the way!

Winsordawson 04-08-2023 01:42 PM

1 Attachment(s)
Hi again,

Happy holidays, if you celebrate. I have a clip where the color seems to spill over in some areas, like in this frame off the top of the woman's right arm. (ChromaShiftSP was applied to the extent possible without affecting other parts of the video).

Attachment 16409

Chroma was fixed through
Code:

MergeChroma(aWarpSharp2(thresh=200,depth=20,type=1).aWarpSharp2(thresh=200,depth=20,type=1))
If I apply the same function but replace MergeChroma with MergeLuma, the problem is fixed but of course the rest of the clip is smoothed. In another NLE I would apply an edge mask so that aWarpSharp2 and MergeLuma only work on the edges, but I am not too familiar with how to do this in Avisynth with its syntax. Do you have any suggestions?

This didn't work:
Code:

warped = aWarpSharp2(thresh=250,depth=50,type=1)
edgemask = mt_edge(mode="prewitt",thY2=150).mt_inpand()

Overlay(last, warped, mask=edgemask)


lordsmurf 04-08-2023 02:19 PM

Well, that's a disturbing image. :sick:

Winsordawson 04-09-2023 10:34 AM

It's a woman lying down during an interpretative dance sequence. She's very much alive and well (except for her shoulder shadow)...Tape is over 40 years old.....

lollo2 04-11-2023 11:35 AM

Quote:

In another NLE I would apply an edge mask so that aWarpSharp2 and MergeLuma only work on the edges, but I am not too familiar with how to do this in Avisynth with its syntax. Do you have any suggestions?
I would work differently on Y and UV planes, but is difficult to asses with an image.

Have a look here https://forum.videohelp.com/threads/...on#post2640813, and ask there; poisondeathray and jagabo are the masters of masking ;)

Winsordawson 04-11-2023 12:13 PM

Thanks again--I'll keep everyone posted on what I find out!

Winsordawson 04-15-2023 08:36 AM

2 Attachment(s)
I uploaded a video segment this time. Is this ghosting? It turns out that MergeLuma with aWarpSharp2 only took part of the effect away, so the masking wasn't necessary and something else might be needed. (This was after MergeChroma/aWarpSharp2 was used, plus ChromaShiftSP). Thanks for any suggestions.

Attachment 16415


All times are GMT -5. The time now is 12:54 AM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.