头像
remixer
帖子: 15
注册时间: 2012-05-28 13:25

[已解决]vs下切奇数像素点的疑问

在压制N制DVD时需要切奇数像素点
avs下LanczosResize直接就可以切奇数 ( 之前看见某贴说是通过补像素凑成偶数实现的,不知真假,那张贴我现在搜了很久找不到了 )

在VS下,用自带的CropRel无法切奇数像素点,请问有没有可以直接切奇数像素点的滤镜?

我现在要切奇数像素点,是用fmtconv先升到YUV444P16

代码: 全选

src = core.fmtc.resample (clip=src, css="444")
切边及Resize完成后再降回YUV420P8

代码: 全选

src = core.fmtc.resample (clip=src, css="420")
src = core.fmtc.bitdepth (clip=src, bits=8)
这样处理相较于直接切应该会带来更多的色彩画质损失,请问此方案有没有优化的空间? 切奇数像素点有没有更好的解决方法?
上次由 remixer 在 2017-12-29 11:53,总共编辑 1 次。
787633258
帖子: 32
注册时间: 2015-07-17 19:55

Re: [求助]vs下切奇数像素点的疑问

和avs类似,vs里内建的resize滤镜和fmtc都能实现(不过写法似乎不一样,具体去查文档吧)。
头像
remixer
帖子: 15
注册时间: 2012-05-28 13:25

Re: [求助]vs下切奇数像素点的疑问

787633258 写了:和avs类似,vs里内建的resize滤镜和fmtc都能实现(不过写法似乎不一样,具体去查文档吧)。
你是指不需转成YUV444直接就切奇数边?

我找了一下
vs说明里的Crop部分
Crop/CropAbs
std.Crop(clip clip[, int left=0, int right=0, int top=0, int bottom=0])
std.CropAbs(clip clip, int width, int height[, int left=0, int top=0])
Crops the frames in a clip.
Crop is the simplest to use of the two. The arguments specify how many pixels to crop from each side. This function used to be called CropRel which is still an alias for it.
CropAbs, on the other hand, is special, because it can accept clips with variable frame sizes and crop out a fixed size area, thus making it a fixed size clip.
Both functions return an error if the whole picture is cropped away, if the cropped area extends beyond the input or if the subsampling restrictions aren’t met.
这个填奇数就报错


vs说明里的Resize部分
resize.Bilinear(clip clip[, int width, int height, int format, enum matrix, enum transfer, enum primaries, enum range, enum chromaloc, enum matrix_in, enum transfer_in, enum primaries_in, enum range_in, enum chromaloc_in, float filter_param_a, float filter_param_b, string resample_filter_uv, float filter_param_a_uv, float filter_param_b_uv, string dither_type="none", string cpu_type, bint prefer_props=False, float src_left, float src_top, float src_width, float src_height, float nominal_luminance])
resize.Bicubic(clip clip[, ...])
resize.Point(clip clip[, ...])
resize.Lanczos(clip clip[, ...])
resize.Spline16(clip clip[, ...])
resize.Spline36(clip clip[, ...])
...
更多地在讲分辨率变换及彩色空间转换,未提及YUV420下的切边

fmtconv的文档说明范围与VS里的Resize部分类似

不知可否再说详细一点?
787633258
帖子: 32
注册时间: 2015-07-17 19:55

Re: [求助]vs下切奇数像素点的疑问

vs内建的resize的话,用src_left, src_top, src_width, src_height来控制裁剪范围
如果写成vs内建的Crop(CropRel)的那种形式的话,就是:

代码: 全选

def rcrop(clip,left=0,top=0,right=0,bottom=0):
	if left<0:
		raise ValueError("rcrop:left mustn't be negative")
	if right<0:
		raise ValueError("rcrop:right mustn't be negative")
	if top<0:
		raise ValueError("rcrop:top mustn't be negative")
	if bottom<0:
		raise ValueError("rcrop:bottom mustn't be negative")
	return clip.resize.Point(clip.width-left-right,clip.height-top-bottom,src_left=left, src_top=top, src_width=clip.width-left-right, src_height=clip.height-top-bottom)
然后rcrop(clip,left,top,right,bottom)调用就行了
头像
remixer
帖子: 15
注册时间: 2012-05-28 13:25

Re: [求助]vs下切奇数像素点的疑问

787633258 写了:vs内建的resize的话,用src_left, src_top, src_width, src_height来控制裁剪范围
如果写成vs内建的Crop(CropRel)的那种形式的话,就是:
然后rcrop(clip,left,top,right,bottom)调用就行了
感谢回复,电脑出了点问题,所以我的回复晚了一点,不好意思

vs内建resize
src_left, src_top, src_width, src_height 这几个参数很奇怪
Used to select the source region of the input to use. Can also be used to shift the image. Defaults to the whole image.
实际效果是切了画面但在切去画面的部分又补上镜像画面,不知该怎么用才对 {:cat_13}

使用你写的这段可以切奇数,但依旧需要左右(或上下)所切之和为偶数
比如 rcrop(clip,5,0,5,0) 是可以的
但 rcrop(clip,5,0,4,0) 就报错了
无法实现AVS下类似 LanczosResize(648,480,4,0,-5,0).crop(4,0,-4,0) 的操作

我具体是这样用的,不知有未用错

代码: 全选

def rcrop(clip,left=0,top=0,right=0,bottom=0):
   if left<0:
      raise ValueError("rcrop:left mustn't be negative")
   if right<0:
      raise ValueError("rcrop:right mustn't be negative")
   if top<0:
      raise ValueError("rcrop:top mustn't be negative")
   if bottom<0:
      raise ValueError("rcrop:bottom mustn't be negative")
   return clip.resize.Point(clip.width-left-right,clip.height-top-bottom,src_left=left, src_top=top, src_width=clip.width-left-right, src_height=clip.height-top-bottom)
src = rcrop(src,5,0,4,0)
787633258
帖子: 32
注册时间: 2015-07-17 19:55

Re: [求助]vs下切奇数像素点的疑问

w=648#输出宽度
h=480#输出高度
left=5
top=0
right=4
bottom=0
clip=clip.resize.Point(w,h,src_left=left, src_top=top, src_width=clip.width-left-right, src_height=clip.height-top-bottom)
头像
remixer
帖子: 15
注册时间: 2012-05-28 13:25

Re: [求助]vs下切奇数像素点的疑问

787633258 写了:w=648#输出宽度
h=480#输出高度
left=5
top=0
right=4
bottom=0
clip=clip.resize.Point(w,h,src_left=left, src_top=top, src_width=clip.width-left-right, src_height=clip.height-top-bottom)
请问这一段要怎么用啊

提示未定义clip,不知道该怎么写

代码: 全选

import vapoursynth as vs
import havsfunc as haf
core = vs.get_core()
ret = core.d2v.Source(input=r'd:\VIDEO_TS\VTS_01_1.d2v')
ret = haf.QTGMC(ret, Preset='slow', FPSDivisor=2, ShutterBlur=2, TFF=True)
w=648
h=480
left=5
top=0
right=4
bottom=0
ret=clip.resize.Point(w,h,src_left=left,src_top=top,src_width=clip.width-left-right,src_height=clip.height-top-bottom)
ret.set_output()
上次由 remixer 在 2017-12-29 11:35,总共编辑 1 次。
787633258
帖子: 32
注册时间: 2015-07-17 19:55

Re: [求助]vs下切奇数像素点的疑问

把clip改成你用的ret
或者把ret改成clip
头像
remixer
帖子: 15
注册时间: 2012-05-28 13:25

Re: [求助]vs下切奇数像素点的疑问

787633258 写了:把clip改成你用的ret
或者把ret改成clip
可以了,终于不用YUV420 YUV444换来换去了 {:husky}
十分感谢
208haf
帖子: 2
注册时间: 2022-09-29 20:54

Re: [已解决]vs下切奇数像素点的疑问

remixer 写了: 2017-12-24 14:39 在压制N制DVD时需要切奇数像素点
avs下LanczosResize直接就可以切奇数 ( 之前看见某贴说是通过补像素凑成偶数实现的,不知真假,那张贴我现在搜了很久找不到了 )

在VS下,用自带的CropRel无法切奇数像素点,请问有没有可以直接切奇数像素点的滤镜?

我现在要切奇数像素点,是用fmtconv先升到YUV444P16

代码: 全选

src = core.fmtc.resample (clip=src, css="444")
切边及Resize完成后再降回YUV420P8

代码: 全选

src = core.fmtc.resample (clip=src, css="420")
src = core.fmtc.bitdepth (clip=src, bits=8)
这样处理相较于直接切应该会带来更多的色彩画质损失,请问此方案有没有优化的空间? 切奇数像素点有没有更好的解决方法?
转yuv420转yuv444的话,还是RGB2OPP, OPP2RGB比较好
大致写法如下:
► 显示剧情透露
与源的差异很小
(当初胡言乱语了
图片

回到 “VapourSynth”