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 29th November 2019, 22:09   #3721  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,055
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   #3722  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,055
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   #3723  |  Link
Lypheo
Registered User
 
Join Date: Sep 2018
Posts: 9
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   #3724  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 52
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   #3725  |  Link
Pat357
Registered User
 
Join Date: Jun 2006
Posts: 439
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   #3726  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 52
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   #3727  |  Link
Lypheo
Registered User
 
Join Date: Sep 2018
Posts: 9
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   #3728  |  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   #3729  |  Link
Pat357
Registered User
 
Join Date: Jun 2006
Posts: 439
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   #3730  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,043
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   #3731  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 52
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   #3732  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 5,929
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
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..

Last edited by Selur; 27th December 2019 at 14:06.
Selur is offline   Reply With Quote
Old 26th December 2019, 19:26   #3733  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 87
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
Old 27th December 2019, 16:25   #3734  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: 36 Chambers
Posts: 5,917
I wish Visual Studio project files were included in the source, so I can use 'Go to document' and 'Go to definition' in order to understand the code. Right now I'm looking at vsvfw.cpp and want to know which header declares IUnknown. Maybe I have to try creating a project file.
stax76 is offline   Reply With Quote
Old 27th December 2019, 16:33   #3735  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,055
Quote:
Originally Posted by stax76 View Post
I wish Visual Studio project files were included in the source, so I can use 'Go to document' and 'Go to definition' in order to understand the code. Right now I'm looking at vsvfw.cpp and want to know which header declares IUnknown. Maybe I have to try creating a project file.
They are included: msvc_project/vapoursynth.sln

IUnknown is obviously from a system COM header.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 27th December 2019, 16:41   #3736  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: 36 Chambers
Posts: 5,917
Sorry, I overlooked it. I'm not very good in C++ right now, first C++ project after over ten years.

Last edited by stax76; 27th December 2019 at 17:41.
stax76 is offline   Reply With Quote
Old 28th December 2019, 21:49   #3737  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,055
Audio support is almost done
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 28th December 2019, 22:10   #3738  |  Link
yoon
Registered User
 
Join Date: Feb 2018
Posts: 5
Quote:
Originally Posted by _Al_ View Post
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.
Thank you for your answer, I didn't know that outputindex option existed. That's great. Will try it this way.
yoon is offline   Reply With Quote
Old 29th December 2019, 10:57   #3739  |  Link
jmartinr
Registered User
 
jmartinr's Avatar
 
Join Date: Dec 2007
Location: Enschede, NL
Posts: 295
__________________
Roelofs Coaching
jmartinr is offline   Reply With Quote
Old 29th December 2019, 13:10   #3740  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 5,929
Quote:
Audio support is almost done
Nice, hoping to view the wave front of an input file to find the audio delay of some files.
Thanks!

Cu Selur
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
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 10:25.


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