Sorry, fixed the syntax for the replaceFrames.py
Code:
from vapoursynth import core
import vapoursynth as vs
def ReplaceFrames(clip: vs.VideoNode, start1: int, end1: int, start2: int, end2: int):
# Extract segments to keep
segment1 = clip[:start1] # From the start to the frame before start1
segment2 = clip[start2:end2 + 1] # From start2 to end2
segment3 = clip[end1 + 1:] # From the frame after end1 to the end
# Combine the segments
return segment1 + segment2 + segment3
then call it in Hybrid under "Filtering->Vapoursynth->Custom->Insert before->ReplacBlackFrames"
Code:
import replaceFrames
# Remplacement des frames 43125 à 43129 par 43120 à 43124
clip = replaceFrames.ReplaceFrames(clip, 43125, 43129, 43120, 43124)
# Remplacement des frames 43301 à 43304 par 43275 à 43278
clip = replaceFrames.ReplaceFrames(clip, 43301, 43304, 43275, 43278)
# Remplacement de la frame 22261 par 22257
clip = replaceFrames.ReplaceFrames(clip, 22261, 22261, 22257, 22257)
# Remplacement de la frame 22262 par 22257
clip = replaceFrames.ReplaceFrames(clip, 22262, 22262, 22257, 22257)
# Remplacement de la frame 22263 par 22256
clip = replaceFrames.ReplaceFrames(clip, 22263, 22263, 22256, 22256)
# Remplacement de la frame 22264 par 22258
clip = replaceFrames.ReplaceFrames(clip, 22264, 22264, 22258, 22258)
# Remplacement de la frame 22437 par 22441
clip = replaceFrames.ReplaceFrames(clip, 22437, 22437, 22441, 22441)
# Remplacement de la frame 22438 par 22442
clip = replaceFrames.ReplaceFrames(clip, 22438, 22438, 22442, 22442)
# Remplacement de la frame 22439 par 22443
clip = replaceFrames.ReplaceFrames(clip, 22439, 22439, 22443, 22443)
# Remplacement de la frame 22440 par 22444
clip = replaceFrames.ReplaceFrames(clip, 22440, 22440, 22444, 22444)
# Remplacement de la frame 22454 par 22453
clip = replaceFrames.ReplaceFrames(clip, 22454, 22454, 22453, 22453)
clip = replaceFrames.ReplaceFrames(clip, 22440, 22440, 22444, 22444)
would create code like:
Code:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# defining beforeReplaceBlackFrames-function - START
def beforeReplaceBlackFrames(clip):
import replaceframes
# Remplacement des frames 43125 à 43129 par 43120 à 43124
clip = replaceFrames.ReplaceFrames(clip, 43125, 43129, 43120, 43124)
# Remplacement des frames 43301 à 43304 par 43275 à 43278
clip = replaceFrames.ReplaceFrames(clip, 43301, 43304, 43275, 43278)
# Remplacement de la frame 22261 par 22257
clip = replaceFrames.ReplaceFrames(clip, 22261, 22261, 22257, 22257)
# Remplacement de la frame 22262 par 22257
clip = replaceFrames.ReplaceFrames(clip, 22262, 22262, 22257, 22257)
# Remplacement de la frame 22263 par 22256
clip = replaceFrames.ReplaceFrames(clip, 22263, 22263, 22256, 22256)
# Remplacement de la frame 22264 par 22258
clip = replaceFrames.ReplaceFrames(clip, 22264, 22264, 22258, 22258)
# Remplacement de la frame 22437 par 22441
clip = replaceFrames.ReplaceFrames(clip, 22437, 22437, 22441, 22441)
# Remplacement de la frame 22438 par 22442
clip = replaceFrames.ReplaceFrames(clip, 22438, 22438, 22442, 22442)
# Remplacement de la frame 22439 par 22443
clip = replaceFrames.ReplaceFrames(clip, 22439, 22439, 22443, 22443)
# Remplacement de la frame 22440 par 22444
clip = replaceFrames.ReplaceFrames(clip, 22440, 22440, 22444, 22444)
# Remplacement de la frame 22454 par 22453
clip = replaceFrames.ReplaceFrames(clip, 22454, 22454, 22453, 22453)
clip = replaceFrames.ReplaceFrames(clip, 22440, 22440, 22444, 22444)
return clip
# defining beforeReplaceBlackFrames-function - END
# Import scripts
import validate
# Source: 'G:\TestClips&Co\files\test.avi'
# Current color space: YUV420P8, bit depth: 8, resolution: 640x352, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading G:\TestClips&Co\files\test.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="G:/TestClips&Co/files/test.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
frame = clip.get_frame(0)
# setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
# setting color transfer (vs.TRANSFER_BT601), if it is not set.
if validate.transferIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
# setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
if validate.primariesIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
clip = beforeReplaceBlackFrames(clip)
# adjusting output color from: YUV420P8 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# output
clip.set_output()
(see Vapoursynth Script Preview)
Cu Selur