Process your VideoNode with the getnative algorithm and return the result and a plot object :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: pre
(args: Union[List, argparse.Namespace], src: vapoursynth.VideoNode, scaler: Union[_DefineScaler, None],
first_time: bool = True)
| 277 | |
| 278 | |
| 279 | async def getnative(args: Union[List, argparse.Namespace], src: vapoursynth.VideoNode, scaler: Union[_DefineScaler, None], |
| 280 | first_time: bool = True) -> Tuple[str, pyplot.plot, GetNative]: |
| 281 | """ |
| 282 | Process your VideoNode with the getnative algorithm and return the result and a plot object |
| 283 | |
| 284 | :param args: List of all arguments for argparse or Namespace object from argparse |
| 285 | :param src: VideoNode from vapoursynth |
| 286 | :param scaler: DefineScaler object or None |
| 287 | :param first_time: prevents posting warnings multiple times |
| 288 | :return: best resolutions string, plot matplotlib.pyplot and GetNative class object |
| 289 | """ |
| 290 | |
| 291 | if type(args) == list: |
| 292 | args = parser.parse_args(args) |
| 293 | |
| 294 | output_dir = Path(args.dir).resolve() |
| 295 | if not os.access(output_dir, os.W_OK): |
| 296 | raise PermissionError(f"Missing write permissions: {output_dir}") |
| 297 | output_dir = output_dir.joinpath("results") |
| 298 | |
| 299 | if (args.img or args.mask_out) and imwri is None: |
| 300 | raise GetnativeException("imwri not found.") |
| 301 | |
| 302 | if scaler is None: |
| 303 | scaler = _DefineScaler(args.kernel, b=args.b, c=args.c, taps=args.taps) |
| 304 | else: |
| 305 | scaler = scaler |
| 306 | |
| 307 | if scaler.plugin is None: |
| 308 | raise GetnativeException('No descale found!') |
| 309 | |
| 310 | if args.steps != 1 and first_time: |
| 311 | print( |
| 312 | "Warning for -steps/--stepping: " |
| 313 | "If you are not completely sure what this parameter does, use the default step size.\n", |
| 314 | file=sys.stderr |
| 315 | ) |
| 316 | |
| 317 | if args.frame is None: |
| 318 | args.frame = src.num_frames // 3 |
| 319 | elif args.frame < 0: |
| 320 | args.frame = src.num_frames // -args.frame |
| 321 | elif args.frame > src.num_frames - 1: |
| 322 | raise GetnativeException(f"Last frame is {src.num_frames - 1}, but you want {args.frame}") |
| 323 | |
| 324 | if args.ar == 0: |
| 325 | args.ar = src.width / src.height |
| 326 | |
| 327 | if args.min_h >= src.height: |
| 328 | raise GetnativeException(f"Input image {src.height} is smaller min_h {args.min_h}") |
| 329 | elif args.min_h >= args.max_h: |
| 330 | raise GetnativeException(f"min_h {args.min_h} > max_h {args.max_h}? Not processable") |
| 331 | elif args.max_h > src.height: |
| 332 | print(f"The image height is {src.height}, going higher is stupid! New max_h {src.height}", file=sys.stderr) |
| 333 | args.max_h = src.height |
| 334 | |
| 335 | getn = GetNative(src, scaler, args.ar, args.min_h, args.max_h, args.frame, args.mask_out, args.plot_scaling, |
| 336 | args.plot_format, args.show_plot, args.no_save, args.steps, output_dir) |
no test coverage detected