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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th March 2019, 13:16   #3281  |  Link
jackoneill
unsigned int
 
jackoneill's Avatar
 
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
Quote:
Originally Posted by _Al_ View Post
I might found a culprit, but not sure what to do with it or how to fix it.

for example NTSC video there is 1 byte per sample, if I get_stride for all three planes:
f = clip.get_frame(0)
print(f.get_stride(0),f.get_stride(1),f.get_stride(2))
I get:
736 384 384 (expected: 720 360 360)
for HDV video from HDV tape camcorder (shooting 1440x1080) I get:
1440 736 736 (expected: 1440 720 720)

after resize I get even values, like resizing NTSC video to 640x480 I'd get:
640 320 320
or resizing that HDV video to 1920x1080, I'd get:
1920 960 960

Those are expected numbers and encoding is also ok, so this looks like a cause to offset the output if resizing is not done. If I resize to the same resolution values stay the same, it would not help.

Is there any way to get those values even without resizing? What are those data that are trailing (or preceding) each line in plane array? If it is not stride itself (wrong value) that offsets things.
This is a known bug which will be fixed in the next release.

There was a bit of code in clip.output() which assumed that the width multiplied by bytes_per_sample is the same as the stride. This is only true when the width multiplied by bytes_per_sample is a multiple of 32.

This is why you have a problem with 720x___ but not with 1280x___, 1440x____ or 1920x____. 720 / 32 = 22.5; 1280 / 32 = 40; 1440 / 32 = 45; 1920 / 32 = 60.

The stride (the distance between two consecutive rows) is not always the same as the width multiplied by bytes_per_sample in order to make every row start at a memory location which is a multiple of 32. (The first row starts at a multiple of 32 because that's what VapourSynth requests from the memory allocator.) This apparently makes filters run faster. The extra (stride - width * bytes_per_sample) bytes are left unused.
__________________
Buy me a "coffee" and/or hire me to write code!
jackoneill is offline   Reply With Quote
Old 15th March 2019, 18:50   #3282  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Thank you for explanation, now when it is clear it is even workable.

Width for output() function now has to be any even number x 32. Multiple of odd number would not work. So any width divided by 32 with even result would work.
Thank you.
_Al_ is offline   Reply With Quote
Old 15th March 2019, 21:24   #3283  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by _Al_ View Post
Thank you for explanation, now when it is clear it is even workable.

Width for output() function now has to be any even number x 32. Multiple of odd number would not work. So any width divided by 32 with even result would work.
Thank you.
This will be fixed in the next release
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 15th March 2019, 21:36   #3284  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Thank you,
that direct export is a fantastic feature where even progress update is available
_Al_ is offline   Reply With Quote
Old 16th March 2019, 00:14   #3285  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by _Al_ View Post
Encoding using clip.output() right from vapoursynth script itself, where input video is ANY anamorphic video like HDV camcorder M2T video or NTSC DV or VOB gives jagged lines....
Some interesting script files you have there. Speaking of which, is there a variable for the running script name itself?
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 16th March 2019, 01:02   #3286  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Not sure if I understand, do you want to give it output name as script name?
You'd use __file__ variable, if you want just basename, you'd do something like:
import os
output_dir = r'F:\Destination'
output = os.path.join(output_dir, os.path.basename(__file__)+'.264')

In practical terms you'd perhaps always import your modul for encoding, you'd put that encoding part as a separate py file and put it in Python\Lib\vapoursynth directory and just import it as a modul in each script and run it. You couldpass the whole cmd line as a variable string and let that sorted out in that modul with shlex.split(cmd as a string) etc.

Last edited by _Al_; 16th March 2019 at 01:07.
_Al_ is offline   Reply With Quote
Old 16th March 2019, 01:38   #3287  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by _Al_ View Post
Not sure if I understand, do you want to give it output name as script name?
You'd use __file__ variable, if you want just basename, you'd do something like:
import os
output_dir = r'F:\Destination'
output = os.path.join(output_dir, os.path.basename(__file__)+'.264')
^^ That's exactly what I wanted to do!
__________________
Gorgeous, delicious, deculture!

Last edited by asarian; 16th March 2019 at 02:11.
asarian is offline   Reply With Quote
Old 16th March 2019, 11:16   #3288  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by _Al_ View Post
Thank you,
that direct export is a fantastic feature where even progress update is available
So, how do you call the script?! When I just try

'VSPipe f:\jobs\test.vpy'

It tells me 'No output file specified'

I must be doing it wrong.
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 16th March 2019, 20:22   #3289  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
vspipe is another (perhaps preferred) way how to encode your script. It pipes frames into an encoder of your choice from OUTSIDE of vapoursynth script *.vpy or *.py,

but method from above, vapoursynth outpus raw frames directly from script itself, you bypass vspipe, but you need to have *.py, not *.vpy because you run Python basically , vapoursynth does its wrapping part in Python and serving frames with clip.output(). You just run script itself with this method and it will start encoding, you can choose a python consol of your choice (IDLE for example came with Python, so you should have it) and pressing F5 or even using VSEditor, but VS Editor needs clip.set_output(), otherwise it would not let script run, therefore encode (and then showing preview). If you want to avoid preview popup after encoding, you'd just evaluate script.

if you do not use a console and prefer windows command line, you'd need to run:
python3 "test.py"
or
python "test.py"

Last edited by _Al_; 16th March 2019 at 20:34.
_Al_ is offline   Reply With Quote
Old 17th March 2019, 14:36   #3290  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Why is the avisynth RemoveDirt.dll only availible if the RemoveDirtVS_x64.dll is not autoloaded.

My steps
core.avs.LoadPlugin(r"D:\avs_plugins64\RemoveDirt.dll") # no loading error
But clip = core.avs.RestoreMotionBlocks(clip) is not availible

Checking with print(core.get_plugins()) confirms that com.fakeurl.removedirtvs is loaded but nothing with avisynth.

Now without RemoveDirtVS_x64.dll
core.avs.LoadPlugin(r"D:\avs_plugins64\RemoveDirt.dll")
print(core.get_plugins()) -> RestoreMotionBlocks is available
Code:
'com.vapoursynth.avisynth': {'namespace': 'avs', 'identifier': 'com.vapoursynth.avisynth', 'name': 'VapourSynth Avisynth Compatibility', 'functions': {'LoadPlugin': 'path:data;', 'RestoreMotionBlocks': 'c1:clip;c2:clip ...
So why is VS-RemoveDirt blocking the avisynth RemoveDirt functions?


VS and AVS dlls: https://www.dropbox.com/s/nkho8s2pje...irtVS.zip?dl=1
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is online now   Reply With Quote
Old 18th March 2019, 04:24   #3291  |  Link
Iron_Mike
Registered User
 
Join Date: Jul 2010
Posts: 132
is it possible to output the version number of a loaded VS plugin ? if so, what is the command ?

Thanks.
Iron_Mike is offline   Reply With Quote
Old 18th March 2019, 10:39   #3292  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by Iron_Mike View Post
is it possible to output the version number of a loaded VS plugin ? if so, what is the command ?

Thanks.
There are no exported version numbers
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 18th March 2019, 22:47   #3293  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by _Al_ View Post
vspipe is another (perhaps preferred) way how to encode your script. It pipes frames into an encoder of your choice from OUTSIDE of vapoursynth script *.vpy or *.py,

but method from above, vapoursynth outpus raw frames directly from script itself, you bypass vspipe, but you need to have *.py, not *.vpy because you run Python basically , vapoursynth does its wrapping part in Python and serving frames with clip.output(). You just run script itself with this method and it will start encoding, you can choose a python consol of your choice (IDLE for example came with Python, so you should have it) and pressing F5 or even using VSEditor, but VS Editor needs clip.set_output(), otherwise it would not let script run, therefore encode (and then showing preview). If you want to avoid preview popup after encoding, you'd just evaluate script.

if you do not use a console and prefer windows command line, you'd need to run:
python3 "test.py"
or
python "test.py"

Thank you!
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 19th March 2019, 01:16   #3294  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
I have this "prop transfer" code:
Code:
def _Transfer(n, f):
   fout = f[0].copy()
   fout.props['_Diff'] = f[1].props['_Diff']
   return fout
alt_clip = core.std.ModifyFrame(alt_clip, [alt_clip, alt_clip_butt], selector=_Transfer)
Is it possible to make _Transfer() more universal, like this _Transfer(n, f, prop_name), so I can pass any prop -> f[1].props[prop_name] ? If yes, how to call/pass it?

@Myrsloik have you seen my RemoveDirt post? https://forum.doom9.org/showthread.p...51#post1869151
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database

Last edited by ChaosKing; 19th March 2019 at 01:42.
ChaosKing is online now   Reply With Quote
Old 19th March 2019, 05:13   #3295  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Quote:
Originally Posted by ChaosKing View Post
I have this "prop transfer" code:
Code:
def _Transfer(n, f):
   fout = f[0].copy()
   fout.props['_Diff'] = f[1].props['_Diff']
   return fout
alt_clip = core.std.ModifyFrame(alt_clip, [alt_clip, alt_clip_butt], selector=_Transfer)
Is it possible to make _Transfer() more universal, like this _Transfer(n, f, prop_name), so I can pass any prop -> f[1].props[prop_name] ? If yes, how to call/pass it?
Code:
from functools import partial

def _Transfer(n, f, prop_name):
   fout = f[0].copy()
   fout.props[prop_name] = f[1].props[prop_name]
   return fout
alt_clip = core.std.ModifyFrame(alt_clip, [alt_clip, alt_clip_butt], selector=partial(_Transfer, prop_name="_Diff"))
WolframRhodium is offline   Reply With Quote
Old 19th March 2019, 10:44   #3296  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Exactly what I wanted, perfect
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is online now   Reply With Quote
Old 19th March 2019, 15:07   #3297  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
When I try to extract planes and merge them back together, I got error "ShufflePlanes: Plane 1 and 2 are not subsampled multiples of first plane"?

Code:
clip_yuv16 = core.resize.Bicubic(clip, format=vs.YUV420P16)

y_clip = core.std.ShufflePlanes(clip_yuv16 , planes=0, colorfamily=vs.YUV)
u_clip = core.std.ShufflePlanes(clip_yuv16 , planes=1, colorfamily=vs.YUV)
v_clip = core.std.ShufflePlanes(clip_yuv16 , planes=2, colorfamily=vs.YUV)

yuv16_new = core.std.ShufflePlanes(clips=[y_clip, u_clip, v_clip], planes=[0,0,0], colorfamily=vs.YUV)
lansing is offline   Reply With Quote
Old 19th March 2019, 15:35   #3298  |  Link
Wolfberry
Helenium(Easter)
 
Wolfberry's Avatar
 
Join Date: Aug 2017
Location: Hsinchu, Taiwan
Posts: 99
Quote:
Originally Posted by lansing View Post
When I try to extract planes and merge them back together, I got error "ShufflePlanes: Plane 1 and 2 are not subsampled multiples of first plane"?

Code:
clip_yuv16 = core.resize.Bicubic(clip, format=vs.YUV420P16)

y_clip = core.std.ShufflePlanes(clip_yuv16 , planes=0, colorfamily=vs.YUV) ←
u_clip = core.std.ShufflePlanes(clip_yuv16 , planes=1, colorfamily=vs.YUV) ←
v_clip = core.std.ShufflePlanes(clip_yuv16 , planes=2, colorfamily=vs.YUV) ←

yuv16_new = core.std.ShufflePlanes(clips=[y_clip, u_clip, v_clip], planes=[0,0,0], colorfamily=vs.YUV)
You need to use GRAY (not YUV) if you want to extract individual planes.
__________________
Monochrome Anomaly
Wolfberry is offline   Reply With Quote
Old 19th March 2019, 15:51   #3299  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by Wolfberry View Post
You need to use GRAY (not YUV) if you want to extract individual planes.
Thanks it works
lansing is offline   Reply With Quote
Old 27th March 2019, 20:17   #3300  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
I'm wondering could someone adjust https://github.com/HENDRIX-ZT2/Deep-Video-Deinterlacing to be used as a Vapoursynth filter? sounds interesting,..
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

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 23:48.


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