Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import json
import urllib3
import certifi
__version__ = '0.1.0'
def main():
apiroot = 'https://www.wanikani.com/api/v2'
@4re
4re / mpls.py
Last active July 24, 2022 12:24
Ugly hack to load mpls in vapoursynth
"""Parse blu-ray .mpls
Code from https://gist.github.com/dk00/0a0634c5666cf1b8ab9f
"""
import os
import collections
import io
import struct
import json
import argparse
from vapoursynth import core
@4re
4re / hdr2sdr.py
Last active September 6, 2021 07:15
from vapoursynth import core, RGBS, YUV444PS
__version__ = '1.1.1'
def hdr2sdr(clip, source_peak=1000, ldr_nits=100, output_foramt=YUV420P8, input_range='limited', output_range='limited', dither='error_diffusion'):
"""Converts HDR footage to SDR.
https://forum.doom9.org/showthread.php?p=1800667#post1800667
Args:
@4re
4re / psharpen.py
Last active January 1, 2023 19:32
from vapoursynth import core, GRAY
__version__ = "1.1.1"
def _clamp(minimum, value, maximum):
return int(max(minimum, min(round(value), maximum)))
def _m4(value, mult=4.0):
from vapoursynth import core
__version__ = "1.1.0"
def nnedi3_rpow2(clip, rfactor=2, width=None, height=None, correct_shift=True,
kernel="spline36", nsize=0, nns=3, qual=None, etype=None, pscrn=None,
opt=True, int16_prescreener=None, int16_predictor=None, exp=None, upsizer=None):
"""nnedi3_rpow2 is for enlarging images by powers of 2.
@4re
4re / knlm.py
Last active November 3, 2020 17:05
from vapoursynth import core, GRAY, YUV
__version__ = "1.0.3"
def knlm_yuv(clip, d=[None, None, None], a=[None, None, None], s=[None, None, None], cmode=None, wmode=None,
h=[None, None, None], rclip=None, device_type=None, info=None, planes=[0]):
"""
Enhanced version of knlmeanscl that supports filtering of all planes on the same call and
pads the image so borders don't be left unfiltered.
@4re
4re / mcdegrainsharp.py
Last active August 6, 2023 20:00
mcdegrainsharp ported to vapoursynth
from vapoursynth import core
def _sharpen(clip, strength, planes):
blur = core.tcanny.TCanny(clip, sigma=strength, mode=-1, planes=planes)
return core.std.Expr([clip, blur], "x x + y -")
def mcdegrainsharp(clip, frames=2, bblur=0.3, csharp=0.3, bsrch=True,
thsad=400, plane=4):
@4re
4re / vshelpers.py
Last active September 14, 2019 02:24
vshelpers, Vapoursynth helpers
import vapoursynth as vs
def clamp(minimum, x, maximum):
return int(max(minimum, min(round(x), maximum)))
def m4(x, m=4.0):
return 16 if x < 16 else int(round(x / m) * m)
@4re
4re / scoll.py
Last active March 20, 2020 19:19
scoll Scritp Collection for Vapoursynth
""" scoll.py +++ Script Collection for VapourSynth: ++++++++++++++++++++++++++++++++++++++++++++++
"""
import vapoursynth as vs
try:
import havsfunc as haf
except:
HAS_HAF = False
else:
HAS_HAF = True
try:
@4re
4re / sharpaamcmod.py
Last active January 9, 2022 08:43
Avisynth's SharpAAMCmod.avsi port to Vapoursynth
# sharpaamcmod.py 2020-11-03
from vapoursynth import core, VideoNode, GRAY
import havsfunc as haf
__version__ = "1.1.1"
def sharpaamcmod(orig, dark=20, thin=10, sharp=0, smooth=0, stabilize=False,
tradius=2, aapel=2, aaov=None, aablk=None, aatype='sangnom'):
"""Ported from: http://forum.doom9.org/showthread.php?p=1673928