Topic: [script] Do interpolation in half resolution?

Hey,

I cant handle 4K sources with my rig and wanted to resize them down to 1080p before interpolation, but i cant get it to work?

This is the important part of my script.py i call from mpv.conf:

refine_params = "[{thsad:2000, search:{distance:2, type:4}}]"
super_params     = "{pel:2,scale:{up:2,Down:4},gpu:1,full:true}"
analyse_params = "{block:{w:32,h:32,overlap:2},main:{levels:4,search:{type:4,distance:-24,sort:true,satd:false,coarse:{type: 4,distance: -5,satd: true,trymany: false,bad: {sad: 1000,range: 0}}},penalty:{lambda: 1.0,plevel: 4.0,lsad: 800,pnew: 5,pglobal: 5,pzero: 10,pnbour: 5,prev: 0}}},refine:" + refine_params + "}"


##THE PROBLEM##
if (clip.width > 1920 or clip.height > 1080): #Just assuming 4K for now so half that since i got a 1080p screen. 
      clip=core.resize.Point(clip, width=clip.width/2, height=clip.height/2, format=vs.YUV420P8)

##This works fine##
if (clip.width <= 1920 or clip.height <= 1080): # 1080p content 
      clip=core.resize.Point(clip, width=clip.width, height=clip.height, format=vs.YUV420P8)

def interpolate(clip):
    
    dst_fps = display_fps
    src_fps_num = int(container_fps * 1e8)
    src_fps_den = int(1e8)
    dst_fps_num = int(dst_fps * 1e4)
    dst_fps_den = int(1e4)
    clip = core.std.AssumeFPS(clip, fpsnum = src_fps_num, fpsden = src_fps_den)
   
    smoothfps_params = "{debug:{vectors:false},rate:{abs:true,den:" + str(dst_fps_den) + ",num:" + str(dst_fps_num) + ",algo:23},cubic: 1,gpuid: 0,linear: true,mask: {cover: 10,area: 0,area_sharp: 1.0},scene: {mode: 0,blend: false,limits: {m1: 3600,m2: 7200,scene: 10400,zero: 10,blocks: 90},luma: 1.5},light: {aspect: 0.0,sar: 1.0,zoom: 0.0,lights: 16,length: 100,cell: 1.0,border: 12}}"
 
    super   = core.svp1.Super(clip,super_params)
    vectors = core.svp1.Analyse(super["clip"],super["data"],clip,analyse_params)
    smooth  = core.svp2.SmoothFps(clip,super["clip"],super["data"],vectors["clip"],vectors["data"],smoothfps_params,src=clip,fps=src_fps)
    smooth  = core.std.AssumeFPS(smooth, fpsnum=smooth.fps_num, fpsden=smooth.fps_den)
    return smooth
  
smooth =  interpolate(clip)
smooth.set_output()

The error when playing 4K materials on my 1080p screen is:

[   0.443][e][vapoursynth] Filter error at frame 0: Resize error 1027: image dimensions must be divisible by subsampling factor
[   0.443][e][vapoursynth] Filter error at frame 1: Resize error 1027: image dimensions must be divisible by subsampling factor
[   0.443][e][vapoursynth] Filter error at frame 2: Resize error 1027: image dimensions must be divisible by subsampling factor
[   0.443][e][vapoursynth] failed, no action taken
[   0.443][e][vf] Disabling filter SVP because it has failed.
[   0.447][d][vapoursynth] destroying VS filters
[   0.449][d][vapoursynth] returning error on reset/uninit

How do i half the clip.width and clip.height when receiving a 4K stream??
I have tested a lot of things like:

if (clip.width > 1920 or clip.height > 1080):
    clip=core.resize.Point(clip,width=round((clip.width) * 0.5),height=round((clip.height) * 0.5),format=vs.YUV420P8)

Nothing works, please if someone who knows this, i need some assistance smile
I am using latest, vapoursynth and compatible python. Have SVP Pro with license.

Re: [script] Do interpolation in half resolution?

So wierd..
This works and plays fine, but am doing interplation on a stream thats higher then what my computer can manage.

cliph = (clip.height/1)
clipw = (clip.width/1)
clip4kh = (clip.height/1.5) ## (clip.height/2.0) doesnt work!##  
clip4kw = (clip.width/1.5) ## (clip.width/2.0) doesnt work!##  

if (clipw > 1920 or cliph > 1080):
    clip=core.resize.Point(clip,width=clip4kw, height=clip4kh,format=vs.YUV420P8)
else:
    clip=core.resize.Point(clip, width=clipw, height=cliph, format=vs.YUV420P8)

(clip.width/2.0) doesnt work for some reason, so i can only scale down the 4K stream to (clip.width/1.5). Any number higher then 1.5 just throws the same:

[   0.443][e][vapoursynth] Filter error at frame 0: Resize error 1027: image dimensions must be divisible by subsampling factor

Driving me nuts this hmm

Re: [script] Do interpolation in half resolution?

Ended up with this ugly thing, but it works on everything iv tested so far:

#4K
#ASPECT RATIO    RESOLUTION
#1.78 (16:9)    3840 x 2160
#1.85    3840 x 2076
#1.90    3840 x 2021
#2.00    3840 x 1920
#2.35    3840 x 1634
#2.37    3840 x 1620
#2.39    3840 x 1607
#2.40    3840 x 1600
#2.44    3840 x 1574

#1080p
#ASPECT RATIO    RESOLUTION
#1.33 (4:3)    1920 x 1440
#1.66 (5:3)    1920 x 1152
#1.78 (16:9)    1920 x 1080
#1.85    1920 x 1038
#1.90    1920 x 1011
#2.00    1920 x 960
#2.35    1920 x 817
#2.37    1920 x 810
#2.39    1920 x 803
#2.40    1920 x 800
#2.44    1920 x 787

if (clip.width > 3800 and clip.height > 2140):
    clip=core.resize.Point(clip,width=1920,height=1080,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 2040 and clip.height < 2090):   
    clip=core.resize.Point(clip,width=1920,height=1030,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 2000 and clip.height < 2040):   
    clip=core.resize.Point(clip,width=1920,height=1011,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 1900 and clip.height < 1940):   
    clip=core.resize.Point(clip,width=1920,height=960,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 1625 and clip.height < 1650):   
    clip=core.resize.Point(clip,width=1920,height=817,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 1615 and clip.height <= 1625):   
    clip=core.resize.Point(clip,width=1920,height=810,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 1603 and clip.height <= 1610):   
    clip=core.resize.Point(clip,width=1920,height=804,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 1590 and clip.height <= 1603):   
    clip=core.resize.Point(clip,width=1920,height=800,format=vs.YUV420P8)
if (clip.width > 3800 and clip.height > 1565 and clip.height <= 1580):   
    clip=core.resize.Point(clip,width=1920,height=787,format=vs.YUV420P8)
if (clip.width < 3800 and clip.height <= 1080):   
    clip=core.resize.Point(clip, width=clip.width, height=clip.height, format=vs.YUV420P8)