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 22nd November 2019, 03:30   #3641  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
http://www.vapoursynth.com/doc/insta...n-via-pip-pypi says that pip install should be done only after Vapoursynth is installed. So what is it for, or what is the purpose of that PIP installation?
_Al_ is offline   Reply With Quote
Old 23rd November 2019, 13:49   #3642  |  Link
MonoS
Registered User
 
Join Date: Aug 2012
Posts: 203
Quote:
Originally Posted by Myrsloik View Post
Yes, that should work and give you the best information.
I've reinstalled my whole system so i am now on a clean OS.
Installed Python 3.7.5 for all user (so it is in "C:\Program Files\Python37" ), installed Vapoursynth R48 and it gives me the same error.

I've then started debuging and the line that is failing is the PyImport_ImportModule in vapoursynth_api.h, the module returned is NULL.
Folder "Lib\site-packages", where i would put my script, is empty, would expect to find file "vapoursynth.pth" and the folder "vapoursynth" (checked in another system with R45), probably is that that is making VSPipe fails?

Last edited by MonoS; 26th November 2019 at 21:14. Reason: The correct version of Vapoursynht is R45, not R46
MonoS is offline   Reply With Quote
Old 23rd November 2019, 21:13   #3643  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Quote:
Originally Posted by Myrsloik View Post
Because the way I'm handling things it's kinda annoying to set them. And it's not like you can ever trust them anyway...
If both timestamps and module version info is missing (it's missing very often in my experience), what else do we have? The file size will be the only thing left and that isn't very much.
stax76 is offline   Reply With Quote
Old 23rd November 2019, 23:05   #3644  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
We have the hash...
https://github.com/vapoursynth/vsrep...t3dfilter.json
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 26th November 2019, 21:23   #3645  |  Link
MonoS
Registered User
 
Join Date: Aug 2012
Posts: 203
Quote:
Originally Posted by MonoS View Post
I've reinstalled my whole system so i am now on a clean OS.
Installed Python 3.7.5 for all user (so it is in "C:\Program Files\Python37" ), installed Vapoursynth R48 and it gives me the same error.

I've then started debuging and the line that is failing is the PyImport_ImportModule in vapoursynth_api.h, the module returned is NULL.
Folder "Lib\site-packages", where i would put my script, is empty, would expect to find file "vapoursynth.pth" and the folder "vapoursynth" (checked in another system with R45), probably is that that is making VSPipe fails?
I think i fixed the issue downloading the portable version of Vapoursynth and putting the file vapoursynth.cp37-win_amd64.pyd inside the site-packages folder under Python37. Hope this could help you fix the problem.
MonoS is offline   Reply With Quote
Old 27th November 2019, 16:28   #3646  |  Link
Lypheo
Registered User
 
Join Date: Sep 2018
Posts: 14
Code:
core.resize.Bicubic(core.std.BlankClip(format=vs.YUV444PS), format=vs.RGB24, matrix_in=1, primaries_in=1, primaries=1) #errors out (Resize error 3074: invalid colorspace definition (1/2/1 => 0/2/1). May need to specify additional colorspace parameters.)
core.resize.Bicubic(core.std.BlankClip(format=vs.YUV444PS), format=vs.RGB24, matrix_in=1, primaries_in=1, primaries=1, transfer_in=1, transfer=1) #works
core.resize.Bicubic(core.std.BlankClip(format=vs.YUV444PS), format=vs.RGB24, matrix_in=1) #works
Seems like a bug to me. vsresize/zimg seems to think it needs to do a primary conversion when in and out primaries are specified (even when equal), and thus demands that the transfer function be specified. This causes the error mentioned above when previewing clips with vsedit (which calls vsresize internally, I presume) that ffms2 attached _Primaries != 2 and _Transfer = 2 to (this is the case for files which have a primaries flag but no transfer flag).
Lypheo is offline   Reply With Quote
Old 29th November 2019, 21:25   #3647  |  Link
Richard1485
Guest
 
Posts: n/a
Quote:
Originally Posted by _Al_ View Post
http://www.vapoursynth.com/doc/insta...n-via-pip-pypi says that pip install should be done only after Vapoursynth is installed. So what is it for, or what is the purpose of that PIP installation?
I was wondering the same thing.
  Reply With Quote
Old 29th November 2019, 22:09   #3648  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by Richard1485 View Post
I was wondering the same thing.
It's useful if you want to install vapoursynth into multiple python environments. The normal installer only lets you choose one.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 4th December 2019, 15:46   #3649  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by Lypheo View Post
Code:
core.resize.Bicubic(core.std.BlankClip(format=vs.YUV444PS), format=vs.RGB24, matrix_in=1, primaries_in=1, primaries=1) #errors out (Resize error 3074: invalid colorspace definition (1/2/1 => 0/2/1). May need to specify additional colorspace parameters.)
core.resize.Bicubic(core.std.BlankClip(format=vs.YUV444PS), format=vs.RGB24, matrix_in=1, primaries_in=1, primaries=1, transfer_in=1, transfer=1) #works
core.resize.Bicubic(core.std.BlankClip(format=vs.YUV444PS), format=vs.RGB24, matrix_in=1) #works
Seems like a bug to me. vsresize/zimg seems to think it needs to do a primary conversion when in and out primaries are specified (even when equal), and thus demands that the transfer function be specified. This causes the error mentioned above when previewing clips with vsedit (which calls vsresize internally, I presume) that ffms2 attached _Primaries != 2 and _Transfer = 2 to (this is the case for files which have a primaries flag but no transfer flag).
You always need to specify both primaries and transfer. You can't do just one. It's how it works.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 5th December 2019, 10:58   #3650  |  Link
Lypheo
Registered User
 
Join Date: Sep 2018
Posts: 14
Quote:
Originally Posted by Myrsloik View Post
You always need to specify both primaries and transfer. You can't do just one. It's how it works.
Yes, I know, but this is about cases where the output primaries are equal to the input primaries (so no conversion is performed). Requiring the transfer parameters to be specified as well in that situation doesn’t make a lot of sense because they’re not needed at all.
Again, this isn’t just a hypothetical case of passing these particular arguments to resize manually: When you have a YCbCR clip that has _Primaries other than 2 but _Transfer == 2 (=undefined) and try to convert to RGB (or to preview with VSEdit), vsresize will throw this error: Resize error 3074: invalid colorspace definition (1/2/1 => 0/2/1). May need to specify additional colorspace parameters.
This behaviour is likely very confusing to the unsuspecting user (as it was to me), because in theory, matrix is all the colorspace parameters that should be needed for a YUV->RGB conversion.

Last edited by Lypheo; 6th December 2019 at 08:10.
Lypheo is offline   Reply With Quote
Old 18th December 2019, 21:02   #3651  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 85
Code:
invalid colorspace definition (1/2/1 => 0/2/1)
What is the order of these numbers? Transfer / Matrix / Primaries ?

I'm getting the error as well, even though I'm not explicitly using the resize function:
Code:
 File "script.py", line 329, in write_img
    print(clip.get_frame(0).props)
  File "src/cython/vapoursynth.pyx", line 1244, in vapoursynth.VideoNode.get_frame
vapoursynth.Error: Resize error: Resize error 3074: invalid colorspace definition (1/2/1 => 0/2/1). May need to specify additional colorspace parameters.
groucho86 is offline   Reply With Quote
Old 23rd December 2019, 01:10   #3652  |  Link
Pat357
Registered User
 
Join Date: Jun 2006
Posts: 452
Are you converting YUV -> RGB somewhere ? Like writing frames from a YUV-clip to RGB-images using "write_img" ?
You're not running vspipe or any other piping and do not use clip.set_output, are you ?
Just plain python.. ? correct ?

I guess it's Matrix /Transfer / Primaries.
I guess VS is complaining because you're going from matrix=1 (=709) to matrix=0 (=RGB) with undef for Transfer, but 1 for primaries.
It would have been no problem if the primaries were also undef (2), but now you 've to specify the other colorspace info as wel.

Please correct me if I'm wrong with this.

Last edited by Pat357; 23rd December 2019 at 01:42.
Pat357 is offline   Reply With Quote
Old 23rd December 2019, 15:28   #3653  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 85
Quote:
Originally Posted by Pat357 View Post
Are you converting YUV -> RGB somewhere ? Like writing frames from a YUV-clip to RGB-images using "write_img" ?
You're not running vspipe or any other piping and do not use clip.set_output, are you ?
Just plain python.. ? correct ?

I guess it's Matrix /Transfer / Primaries.
I guess VS is complaining because you're going from matrix=1 (=709) to matrix=0 (=RGB) with undef for Transfer, but 1 for primaries.
It would have been no problem if the primaries were also undef (2), but now you 've to specify the other colorspace info as wel.

Please correct me if I'm wrong with this.
Hi Pat357, you're correct - pure python, no vspipe. Going from YUV to RGB, but also potentially staying in YUV. Here's an H.264 sample rendered out of Resolve (.mov ProRes and DNxHD react the same way):
https://www.mediafire.com/file/gzacc..._h264.mov/file

Reproduced the issue in vsedit. This fails:
Code:
import vapoursynth as vs
core = vs.get_core()

clip =  core.ffms2.Source(source='bars_h264.mov')

clip = core.text.FrameProps(clip)

clip.set_output()
My workaround for now:
Code:
import vapoursynth as vs
core = vs.get_core()

clip =  core.ffms2.Source(source='bars_h264.mov')

clip = core.text.FrameProps(clip)

if clip.get_frame(0).props['_Transfer'] == 2:
        clip = core.std.SetFrameProp(clip, prop="_Transfer", intval=1)

clip.set_output()
Same behavior with LibavSMASHSource. Is there a more elegant way of dealing with it?
groucho86 is offline   Reply With Quote
Old 23rd December 2019, 15:53   #3654  |  Link
Lypheo
Registered User
 
Join Date: Sep 2018
Posts: 14
Seems like this is the exact issue I talked about a earlier (or rather a consequence of it), namely zimg requiring the transfer func to be specified too when the primaries are given (even implicitly as frame properties) despite it not being needed at all for the conversion.
Lypheo is offline   Reply With Quote
Old 23rd December 2019, 18:06   #3655  |  Link
yoon
Registered User
 
Join Date: Feb 2018
Posts: 5
Hi,

I want to crop a video into four parts and separate each part into its own video. It would be like:

clip.mkv -> Crop Top Left -> clip1.mkv
clip.mkv -> Crop Top Right -> clip2.mkv
clip.mkv -> Crop Bottom Left -> clip3.mkv
...

So far, the cropping seems to be fine, but I don't know how to cut the frames and output multiple files, instead of one.

This is my script:

Code:
import vapoursynth as vs

core = vs.get_core()

clip = core.lsmas.LWLibavSource(source=r'clip.mkv')

clip = core.std.Trim(clip, 0, 59)

clip = core.fmtc.resample(clip, w=600, h=338, css="444", kernel="spline36")
clip = core.fmtc.bitdepth(clip, bits=8)

h = clip.height

h_n = h // 2

clip1 = core.std.CropAbs(clip, x=0, y=0, width=299, height=h_n-0.5) #Top Left
clip2 = core.std.CropAbs(clip, x=300, y=0, width=299, height=h_n-0.5) #Top Right
clip3 = core.std.CropAbs(clip, x=0, y=h_n+0.5, width=299, height=h_n-0.5) #Bottom Left
clip4 = core.std.CropAbs(clip, x=300, y=h_n+0.5, width=299, height=h_n-0.5) #Bottom Right

clip = clip1 + clip2 + clip3 + clip4

clip.set_output()
Is there a simple way to do this?
yoon is offline   Reply With Quote
Old 23rd December 2019, 18:52   #3656  |  Link
Pat357
Registered User
 
Join Date: Jun 2006
Posts: 452
Quote:
Originally Posted by groucho86 View Post
https://www.mediafire.com/file/gzacc..._h264.mov/file

Reproduced the issue in vsedit. This fails:
Code:
import vapoursynth as vs
core = vs.get_core()

clip =  core.ffms2.Source(source='bars_h264.mov')

clip = core.text.FrameProps(clip)

clip.set_output()

Same behavior with LibavSMASHSource. Is there a more elegant way of dealing with it?
Yes, maybe you shouldn't use VSEdit to view the VPY files. ;-) For viewing with VSEdit, a conversion from YUV to RGB is needed.
Without your workaround, you can still open the .VPY file in anything that understands YUV : VirtualDub, or any mediaplayer like MPC-HC, MPV, FFplay, ...
Also encoding works without the work-around as all encoders understand YUV.

Last edited by Pat357; 24th December 2019 at 13:07.
Pat357 is offline   Reply With Quote
Old 24th December 2019, 20:06   #3657  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by groucho86 View Post
Here's an H.264 sample rendered out of Resolve (.mov ProRes and DNxHD react the same way


Another approach would be to tag all 3 matrix/transfer/primaries .

Note that was a change in Resolve 16.x behavior from previous . Older versions tagged all 3 by default. There is some discussion about this on the Resolve forum, and you can see it tags differently depending on the timeline settings
https://forum.blackmagicdesign.com/v...?f=21&t=101253


Or you can also do it afterwards , for AVC, HEVC, or Prores with ffmpeg bitstream filters without re-encoding . But there isn't one for DNxHD/DNxHR

https://ffmpeg.org/ffmpeg-bitstream-...4_005fmetadata
https://ffmpeg.org/ffmpeg-bitstream-...c_005fmetadata
https://ffmpeg.org/ffmpeg-bitstream-...s_005fmetadata
poisondeathray is offline   Reply With Quote
Old 24th December 2019, 21:11   #3658  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 85
Quote:
Originally Posted by poisondeathray View Post
Another approach would be to tag all 3 matrix/transfer/primaries .

Note that was a change in Resolve 16.x behavior from previous . Older versions tagged all 3 by default.
Aha, that explains it! I'm now on Resolve 16.1.2 and was on 15.3.1 for quite a while. Thanks for the explanation!

I've occasionally used BBC's tool as well:
https://github.com/bbc/qtff-parameter-editor
groucho86 is offline   Reply With Quote
Old 26th December 2019, 07:34   #3659  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Can someone with MSVC 2017 or 2019 compile a static version of https://github.com/sekrit-twc/EdgeFixer which does not rely on tons of dlls like the currently linked version in the release section?
-> Problem solved: seems like something with my Windows installation was 'off'
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 27th December 2019 at 14:06.
Selur is offline   Reply With Quote
Old 26th December 2019, 19:26   #3660  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Quote:
Originally Posted by yoon View Post
Is there a simple way to do this?
Not sure if I understand, do you want to encode each cropped clip separately?
You can use vspipe --outputindex to specify what output to process
Code:
import vapoursynth as vs
from vapoursynth import core

clip = core.lsmas.LWLibavSource(source=r'clip.mkv')
clip = core.std.Trim(clip, 0, 59)
clip = core.resize.Bicubic(clip, 600,340)

new_resolution = (clip.width/2, clip.height/2)

clip1 = core.std.CropAbs(clip, *new_resolution, top=0, left=0,          )             #Top Left
clip2 = core.std.CropAbs(clip, *new_resolution, top=0, left=clip.width/2)             #Top Right
clip3 = core.std.CropAbs(clip, *new_resolution, top=clip.height/2, left=0)            #Bottom Left
clip4 = core.std.CropAbs(clip, *new_resolution, top=clip.height/2, left=clip.width/2) #Bottom Right

clip1.set_output(1)
clip2.set_output(2)
clip3.set_output(3)
clip4.set_output(4)

clip = clip1 + clip2 + clip3 + clip4
clip.set_output() #if not stated , default is zero: clip.set_output(0)
and when using command line:
vspipe --y4m your_script.vpy - | ffmpeg -f yuv4mpegpipe .. ....default is output zero
vspipe --outputindex 1 --y4m your_script.vpy - | ffmpeg -f yuv4mpegpipe ....... for clip1
vspipe --outputindex 2 --y4m your_script.vpy - | ffmpeg -f yuv4mpegpipe ....... etc for each output

odd video dimensions cannot be used here, it has to be at least even, (mod 2). In Vapoursynth it depends on video subsampling.
_Al_ 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 00:13.


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