Selur's Little Message Board

Full Version: vhs-bordercontrol, telecide() and (ml)degrain in vapoursynth
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Did a quick test with, loading my version.py:
Code:
import vapoursynth as vs
core = vs.core
import site
clip = core.std.BlankClip()
clip = core.text.Text(clip, core.version())
audio = vs.core.std.BlankAudio()
clip = core.std.Trim(clip=clip, first=0, last=1)
clip.set_output(index=0)
audio.set_output(index=1)
Properly loads in Hybrid. (without audio, but with no length problem)
=> no clue why it's not working for you, my guess is that something is wrong with the script.

Problem also is that vspipe doesn't output any info that there are additional indexes.
Code:
VSPipe.exe --info c:\Users\Selur\Desktop\version.vpy -o 0
and
Code:
VSPipe.exe --info c:\Users\Selur\Desktop\version.vpy
both output:
Code:
Width: 640
Height: 480
Frames: 2
FPS: 24/1 (24.000 fps)
Format Name: RGB24
Color Family: RGB
Alpha: No
Sample Type: Integer
Bits: 8
SubSampling W: 0
SubSampling H: 0
and only:
Code:
VSPipe.exe --info c:\Users\Selur\Desktop\version.vpy -o 1
outputs:
Code:
Samples: 441000
Sample Rate: 44100
Format Name: Audio16 (2 CH)
Sample Type: Integer
Bits: 16
Channels: 2
Layout: Front Left, Front Right
since I don't think there is a restriction (aside from maxint) for possible indexes, blind testing all indexes is a bad idea,...
Also I think there is no delay info there and I don't know whether Vapoursynth even handles delays at all,...

Cu Selur

Ps.: Asked Myrsloik about it over at doom9 and created an issue entry https://github.com/vapoursynth/vapoursynth/issues/1060, he already wrote:
Quote:Makes sense but there are a few problems.
Some people parse the info output so changing it would break things.
There's also no actual api function to obtain the set output indices so that needs to be added as well.
Create an issue and I'll probably do it in a bit.
so there is hope, but since there isn't an API function of it, this will probably only come with a new Vapoursynth release that changes the api.
thanks for your deep investigation of audio not loading!

something i already thought of previously: vapour and most encoders you use beneath hybrid gui are not really ment to be used as "integrated" audio and video solutions like, for example, when u use .avi with vdub and avs. audio is always present, i don't have to worry, i don't have to load it separetely.
this probably stems from historical switch to dvd ripping and everything it entitles, ie it entitles splitting audio and video to process/compress, then merging them at the end.

Quote:Properly loads in Hybrid. (without audio, but with no length problem)
=> no clue why it's not working for you, my guess is that something is wrong with the script.

in that case it wouldn't be loading in vdub too.
but it does.
it probably has to do with which decoders are used.....
your script is synthetic, blank clip, mine is mjpeg.avi, which you can try for yourself with my script.....the link to video is in the first post.
there's probably some sort of "lost in translation" issue, maybe depending on input options (decoders) used....

if you remember, i installed python and vapour in addition to hybrid (to be able to load .vpy to vdub2), dunno if that could cause any weird interactions(?).

but none of that is important if audio can't be piped to hybrid anyway. but it's interesting anomaly.
one can, offcourse, compress that script via vdub2, because it's working there.

i attached the dubug. kinda big, forgot to turn it off few months ago...
.vpy script attached too.


Quote:PAR != DAR. Whether you want to preserve the vertical or horizontal resolution to the original can be configured in Hybrid,...
My screenshot was just to show that 64:45 seems to be the correct input PAR, not that it would create a 4:3 DAR.

par, dar, and then the --sar option in x264! Big Grin 
your screenshot kinda-sorta looks ok untill you compare it to source clip of 480x576 but set to 4:3 ar in player or vdub.
but i can see why you reached for mpeg2 16:9 PAR, it makes some sense.

after some trial and error, tinkering, and even some math, i figured it out and solved it.
here's the ratio:
480/576=0.8333333333333333333333 ratio (yeap, i need more decimals)
4/3=1.333333333333333333

1.333333333333333 / 0.8333333333333333333 =1.6

so 1.6 is our "correction ratio" we need to apply to 480x576(0.83) to get 768x576(4:3).
so now we need to find fraction that best represents it.
that would be 64:40 (64/40=1.6), ie we'll input --sar 64:40 to x264 via hybrid's 'misc' tab of "crop/resize" dialog,  the "overwrite input par" section.
nothing else in "crop/resize", just "overwrite par" on 'misc' tab. everything else is off. no resize, letterbox,   whatever.

this yields proper 4:3 on playback.

how to check?
play with mpc-hc, then "file->save image". is the image 768x576?
if it's not, sar (better to say par) is wrong.
it's interesting that even small drifts from 64:40 par will yield mediainfo suggesting it's 4:3 DAR, but on playback it's not 768x576.
for example, 84/54 ratio yields 746*576 image.
39/25 yields 748*576.
64/41 yields 749*576.
(how do i even know this? because first time i didn't use enough decimals, 1.3/0.83=1.566 and i used that instead of 1.6)

another way to check is to use pot player and drag the borders of player window until you achieve 768x576 window (dragging the borders produces resolution printout in top left of the screen), then compare screenshot of that player (both player and paused video inside, i used "faststone capture" to capture that screen) to original source video set to 4:3 ar in player.
any ar difference will be visible on cycling these two images in, for exampe, irfanview.

so that settles that issue.

i have also previously used "overwrite input par" in conjuction with resize to upscale 480x576 (4:3 DAR) for yt:
set "overwrite input par" to 3/4, set upscale (on 'base' tab of "crop/resize") to 1920x1080.
done.
test?
i compared actual picture dimensions on tv-screen. sd 480x576 (4:3) source and 10920x1080 (also 4:3!) hd encoding had same dimensions, ar is preserved.
Quote:if you remember, i installed python and vapour in addition to hybrid (to be able to load .vpy to vdub2), dunno if that could cause any weird interactions(?).
Yes, that can break everything.

Quote:i attached the dubug. kinda big, forgot to turn it off few months ago...
I deleted everything before '2024.05.19'.

Code:
2024.05.19 - 00:17:36_Windows 11 Version 23H2 (64bit)_2023.12.22.1 - level 9: tool(2): "C:\Program Files\Hybrid\64bit\Vapoursynth\vspipe.exe"
2024.05.19 - 00:17:36_Windows 11 Version 23H2 (64bit)_2023.12.22.1 - level 9: arguments(2):
  --info
  C:\Video\tivtc 50 and ml degrain tempPreviewVapoursynthFile05_03_13_984.vpy
  -
2024.05.19 - 00:17:36_Windows 11 Version 23H2 (64bit)_2023.12.22.1 - level 9: Collected error output:


2024.05.19 - 00:17:36_Windows 11 Version 23H2 (64bit)_2023.12.22.1 - level 9: Collected error output:
Script evaluation failed:
Python exception: No attribute with the name bs exists. Did you mistype a plugin namespace?

Traceback (most recent call last):
  File "src\\cython\\vapoursynth.pyx", line 3124, in vapoursynth._vpy_evaluate
  File "src\\cython\\vapoursynth.pyx", line 3125, in vapoursynth._vpy_evaluate
  File "C:\Video\tivtc 50 and ml degrain tempPreviewVapoursynthFile05_03_13_984.vpy", line 28, in <module>
    audio = core.bs.AudioSource(source=r"C:/Video/netwr0k video cache/vhs_tdk_240_mamets theater_12sec killing telecide with laced subs.avi")
            ^^^^^^^
  File "src\\cython\\vapoursynth.pyx", line 2639, in vapoursynth._CoreProxy.__getattr__
  File "src\\cython\\vapoursynth.pyx", line 2494, in vapoursynth.Core.__getattr__
AttributeError: No attribute with the name bs exists. Did you mistype a plugin namespace?
You are using stuff that exists in your global installation, but does not in the portable installation.
That is why 'pspipe --info "Path to script"' fails and thus Hybrid can't analyse the file.

Quote:par, dar, and then the --sar option in x264!
sar option in x264 is what is called PAR in Hybrid.

Quote:that would be 64:40 (64/40=1.6), ie we'll input --sar 64:40 to x264 via hybrid's 'misc' tab of "crop/resize" dialog, the "overwrite input par" section.
setting the input par in "Crop/Resize->Base->Pixel Aspect Ratio (PAR)->Input PAR" is the usual approach, "Crop/Resize->Misc->Overwrite input PAR" is the way to go if you have multiple files which have no flags,...

Cu Selur
when i encoded the whole movie i noticed gradual a/v async towards the end of the file, ie ok at the beginning, but by the end visible loss of lipsync.

i think vapour (ie vapour source plugins) lacks the avisource approach of vdub and avs, so the dropped frames in the .avi file are not accounted for and they accumulate and cause audio-video drift. 
ie none of the loaders vapour has employs the vdub loader (which was probably just copy/pasted into avs in the beginning).

time, again, is not on my side.  Big Grin

the solution should be to use avs in the hybrid and to check "avisource" in the source options, but i didn't try this, because i noticed some shimmer in the way qtgmc treats graphics on the screen (tv station logos, subtitles....), even slowest setting mangles it a bit....are you aware if qtgmc did ever have some optimisations for sharp graphics? 
another solution would be to re-save the file in vdub with some lossless compression, that way vdub deals with dropped frames, ie it gets rid of those flags and just makes normal avi file without drops. 

another question here: you're not exposing the avs preview script in a same way it's easy to find a vpy script in temp folder? 
is it completely internal to hybrid, or it can be found in some dark corner of some temp folder?  Wink

hold on
Code:
  --input
  C:\Users\i4004\AppData\Local\Temp\tempPreviewAvisynthFile13_26_31_399.avs

Code:
ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("C:\Program Files\Hybrid\32bit\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("C:\Program Files\Hybrid\32bit\avisynthPlugins\RgTools.dll")
LoadPlugin("C:\Program Files\Hybrid\32bit\avisynthPlugins\masktools2.dll")
LoadPlugin("C:\Program Files\Hybrid\32bit\avisynthPlugins\mvtools2.dll")
LoadPlugin("C:\Program Files\Hybrid\32bit\avisynthPlugins\nnedi3.dll")
Import("C:\Program Files\Hybrid\32bit\avisynthPlugins\mtmodes.avsi")
Import("C:\Program Files\Hybrid\32bit\avisynthPlugins\QTGMC.avsi")
Import("C:\Program Files\Hybrid\32bit\avisynthPlugins\Zs_RF_Shared.avsi")
# loading source: C:\Video\00138_no tripod stabi.mkv
# color sampling YV12@8, matrix: bt709, scantyp: top field first, luminance scale: limited
LWLibavVideoSource("C:\Video\00138_no tripod stabi.mkv",cache=false,format="YUV420P8", prefer_hw=0)
# current resolution: 1920x1080
# deinterlacing
AssumeTFF()
QTGMC(Preset="Slow", ediThreads=2)
# adjust color to RGB32 (color matrix: Rec709)
ConvertToRGB32(matrix="Rec709")
PreFetch(6)
#  output: color sampling RGB32@8, matrix: bt709, scantyp: progressive, luminance scale: limited
return last


there it is...it's erased as soon as preview is closed.
Vapoursynth has AviSource, too.

Quote:there it is...it's erased as soon as preview is closed.
Same for Vapoursynth unless something crashes.

Cu Selur
Pages: 1 2