Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
if args.frame is None:
args.frame = src.num_frames // 3
elif args.frame < 0:
args.frame = src.num_frames // -args.frame
elif args.frame > src.num_frames - 1:
raise GetnativeException(f"Last frame is {src.num_frames - 1}, but you want {args.frame}")
if args.ar == 0:
args.ar = src.width / src.height
if args.min_h >= src.height:
raise GetnativeException(f"Input image {src.height} is smaller min_h {args.min_h}")
elif args.min_h >= args.max_h:
raise GetnativeException(f"min_h {args.min_h} > max_h {args.max_h}? Not processable")
elif args.max_h > src.height:
print(f"The image height is {src.height}, going higher is stupid! New max_h {src.height}")
args.max_h = src.height
getn = GetNative(src, scaler, args.ar, args.min_h, args.max_h, args.frame, args.mask_out, args.plot_scaling,
args.plot_format, args.show_plot, args.no_save, args.steps, output_dir)
try:
loop = asyncio.get_event_loop()
best_value, plot, resolutions = loop.run_until_complete(getn.run())
except ValueError as err:
raise GetnativeException(f"Error in getnative: {err}")
gc.collect()
print(
f"\n{scaler} AR: {args.ar:.2f} Steps: {args.steps}\n"
f"{best_value}\n"
if not os.access(output_dir, os.W_OK):
raise PermissionError(f"Missing write permissions: {output_dir}")
output_dir = output_dir.joinpath("results")
if (args.img or args.mask_out) and imwri is None:
raise GetnativeException("imwri not found.")
if scaler is None:
scaler = _DefineScaler(args.kernel, b=args.b, c=args.c, taps=args.taps)
else:
scaler = scaler
if scaler.plugin is None:
if "toggaf.asi.xe" in core.get_plugins():
print("Error: descale_getnative support ended, pls use https://github.com/Irrational-Encoding-Wizardry/vapoursynth-descale")
raise GetnativeException('No descale found!')
if args.steps != 1 and first_time:
print(
"Warning for -steps/--stepping: "
"If you are not completely sure what this parameter does, use the default step size.\n"
)
if args.frame is None:
args.frame = src.num_frames // 3
elif args.frame < 0:
args.frame = src.num_frames // -args.frame
elif args.frame > src.num_frames - 1:
raise GetnativeException(f"Last frame is {src.num_frames - 1}, but you want {args.frame}")
if args.ar == 0:
args.ar = src.width / src.height
if ext in {".py", ".pyw", ".vpy"}:
print("Using custom VapourSynth script as a source. This may cause garbage results. Only do this if you know what you are doing.")
return vpy_source_filter
source_filter = get_attr(core, 'ffms2.Source')
if source_filter:
print("Using ffms2 as source filter")
return lambda input_file: source_filter(input_file, alpha=False)
source_filter = get_attr(core, 'lsmas.LWLibavSource')
if source_filter:
print("Using lsmas.LWLibavSource as source filter")
return source_filter
source_filter = get_attr(core, 'lsmas.LSMASHVideoSource')
if source_filter:
print("Using lsmas.LSMASHVideoSource as source filter")
return source_filter
raise GetnativeException("No source filter found.")
:param args: List of all arguments for argparse or Namespace object from argparse
:param src: VideoNode from vapoursynth
:param scaler: DefineScaler object or None
:param first_time: prevents posting warnings multiple times
:return: best resolutions list and plot matplotlib.pyplot
"""
if type(args) == list:
args = parser.parse_args(args)
output_dir = Path(args.dir).resolve()
if not os.access(output_dir, os.W_OK):
raise PermissionError(f"Missing write permissions: {output_dir}")
output_dir = output_dir.joinpath("results")
if (args.img or args.mask_out) and imwri is None:
raise GetnativeException("imwri not found.")
if scaler is None:
scaler = _DefineScaler(args.kernel, b=args.b, c=args.c, taps=args.taps)
else:
scaler = scaler
if scaler.plugin is None:
if "toggaf.asi.xe" in core.get_plugins():
print("Error: descale_getnative support ended, pls use https://github.com/Irrational-Encoding-Wizardry/vapoursynth-descale")
raise GetnativeException('No descale found!')
if args.steps != 1 and first_time:
print(
"Warning for -steps/--stepping: "
"If you are not completely sure what this parameter does, use the default step size.\n"
)
def check_input(self):
if self.descaler is None and self.kernel == "spline64":
raise GetnativeException(f'descale: spline64 support is missing, update descale (>r3).')
elif self.descaler is None:
raise GetnativeException(f'descale: {self.kernel} is not a supported kernel.')
def check_input(self):
if self.descaler is None and self.kernel == "spline64":
raise GetnativeException(f'descale: spline64 support is missing, update descale (>r3).')
elif self.descaler is None:
raise GetnativeException(f'descale: {self.kernel} is not a supported kernel.')