Skip to content

Instantly share code, notes, and snippets.

@RyougiKukoc
RyougiKukoc / adaptive_grain.py
Created May 27, 2022 08:43
adaptive_grain from kagefunc@8d3f377c37348cd4ec9fd706f707aa0bbc20f8e2
def adaptive_grain(clip: vs.VideoNode, strength=0.25, static=True, luma_scaling=12, show_mask=False) -> vs.VideoNode:
"""
Generates grain based on frame and pixel brightness. Details can be found here:
https://kageru.moe/blog/article/adaptivegrain
Strength is the strength of the grain generated by AddGrain, static=True for static grain, luma_scaling
manipulates the grain alpha curve. Higher values will generate less grain (especially in brighter scenes),
while lower values will generate more grain, even in brighter scenes.
"""
import numpy as np
@RyougiKukoc
RyougiKukoc / defilmgrain.py
Last active November 26, 2022 19:39
A function to reduce film grain, included in rksfunc, public here.
from vapoursynth import core, VideoNode
def defilmgrain(clip: VideoNode, s1=16, s2=3, s3=3, g=1.5, dark=10000) -> VideoNode:
from vapoursynth import YUV, GRAY, Error
from fvsfunc import Depth
from havsfunc import QTGMC
from muvsfunc import MergeChroma
from vsutil import get_y, iterate
from dfttest2 import DFTTest
@RyougiKukoc
RyougiKukoc / SplitEncodeMerge.py
Last active March 2, 2024 21:02
Split, Encode then Merge for closed GOP hevc or avc file.
# In my (and Magic-Raws') configue, mkvmerge is placed in system path,
# VSPipe.exe in sys.prefix, and x265 (plus x264) in sys.prefix//x26x, so that is default in this function.
def SEM(
fp_vc_input: str,
segment_list: list,
fp_qpfile: str,
x26x_param: str,
fp_vpy: str,
fp_vc_output: str,
force_expand: bool = True
def GCFQP(
vcfile: str,
qpfile: str,
output_chapter: str
):
import xml.etree.ElementTree as xet
import os
os.system(f'mkvmerge -o tmp.mkv "{vcfile}"')
os.system('ffprobe -hide_banner -v error -threads auto -show_frames -of xml -select_streams v:0 -i tmp.mkv > tmp.xml')
@RyougiKukoc
RyougiKukoc / exaudio.py
Created May 3, 2023 06:40
mkv / m2ts audio extractor
import os
import argparse
import sys
import time
import msvcrt
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-d', type=str, default='./',
help='-d: specify the path to your workspace')
@RyougiKukoc
RyougiKukoc / havsfunc.py
Last active July 4, 2026 16:32
HAvsFunc <7f0a9a7a37b60a05b9f408024d203e511e544a61> with mod
"""
Holy's ported AviSynth functions for VapourSynth.
Main functions:
daa
daa3mod
mcdaa3
santiag
FixChromaBleedingMod
Deblock_QED
@RyougiKukoc
RyougiKukoc / linear_comparison.py
Last active October 26, 2024 17:17
Need to keepthe same number of m2ts and mkv
import vapoursynth as vs
import rksfunc as rks
import os
import random
from awsmfunc import FrameInfo
from math import ceil
from mvsfunc import ToRGB
core = vs.core
core.max_cache_size = 25600
from vapoursynth import core
from muvsfunc import SSIM_downsample
__version__ = "k.1.1.0"
def nnedi3_rpow2(clip, rfactor=2, width=None, height=None, correct_shift=True,
kernel="SSIM", nsize=0, nns=3, qual=None, etype=None, pscrn=None,
opt=True, int16_prescreener=None, int16_predictor=None, exp=None, upsizer=None):
@RyougiKukoc
RyougiKukoc / flac2alac.py
Created September 5, 2024 12:04
transcode flac into alac in mkv files
import os
import subprocess as sp
recursive = True
src_dir = '.'
src_dir = os.path.abspath(src_dir)
def encode(tar_fp, dst_dir_fp):
dst_fp = os.path.join(dst_dir_fp, os.path.basename(tar_fp).replace('FLAC', 'ALAC'))
p = sp.Popen(['mkvmerge', '-i', tar_fp], stdout=sp.PIPE, stderr=sp.PIPE)
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Whenever you add an architecture to this page, please also update
`tests/models/registry.py` with example HuggingFace models for it.
"""
import importlib
import os
import pickle
import subprocess