|
21 | 21 | from auto_editor.lib.data_structs import Sym
|
22 | 22 | from auto_editor.render.subtitle import SubtitleParser
|
23 | 23 | from auto_editor.utils.cmdkw import (
|
24 |
| - ParserError, |
25 | 24 | Required,
|
26 |
| - parse_with_palet, |
27 | 25 | pAttr,
|
28 | 26 | pAttrs,
|
29 | 27 | )
|
30 |
| -from auto_editor.utils.func import boolop |
31 | 28 | from auto_editor.wavfile import read
|
32 | 29 |
|
33 | 30 | if TYPE_CHECKING:
|
|
38 | 35 | from numpy.typing import NDArray
|
39 | 36 |
|
40 | 37 | from auto_editor.ffwrapper import FileInfo
|
41 |
| - from auto_editor.lib.data_structs import Env |
42 | 38 | from auto_editor.output import Ensure
|
43 | 39 | from auto_editor.utils.bar import Bar
|
44 | 40 | from auto_editor.utils.log import Log
|
@@ -412,81 +408,3 @@ def motion(self, s: int, blur: int, width: int) -> NDArray[np.float64]:
|
412 | 408 |
|
413 | 409 | self.bar.end()
|
414 | 410 | return self.cache("motion", mobj, threshold_list[:index])
|
415 |
| - |
416 |
| - |
417 |
| -def edit_method(val: str, filesetup: FileSetup, env: Env) -> NDArray[np.bool_]: |
418 |
| - assert isinstance(filesetup, FileSetup) |
419 |
| - src = filesetup.src |
420 |
| - tb = filesetup.tb |
421 |
| - ensure = filesetup.ensure |
422 |
| - strict = filesetup.strict |
423 |
| - bar = filesetup.bar |
424 |
| - temp = filesetup.temp |
425 |
| - log = filesetup.log |
426 |
| - |
427 |
| - if ":" in val: |
428 |
| - method, attrs = val.split(":", 1) |
429 |
| - else: |
430 |
| - method, attrs = val, "" |
431 |
| - |
432 |
| - levels = Levels(ensure, src, tb, bar, temp, log) |
433 |
| - |
434 |
| - if method == "none": |
435 |
| - return levels.none() |
436 |
| - if method == "all/e": |
437 |
| - return levels.all() |
438 |
| - |
439 |
| - try: |
440 |
| - obj = parse_with_palet(attrs, builder_map[method], env) |
441 |
| - except ParserError as e: |
442 |
| - log.error(e) |
443 |
| - |
444 |
| - try: |
445 |
| - if method == "audio": |
446 |
| - s = obj["stream"] |
447 |
| - if s == "all" or s == Sym("all"): |
448 |
| - total_list: NDArray[np.bool_] | None = None |
449 |
| - for s in range(len(src.audios)): |
450 |
| - audio_list = to_threshold(levels.audio(s), obj["threshold"]) |
451 |
| - if total_list is None: |
452 |
| - total_list = audio_list |
453 |
| - else: |
454 |
| - total_list = boolop(total_list, audio_list, np.logical_or) |
455 |
| - |
456 |
| - if total_list is None: |
457 |
| - if strict: |
458 |
| - log.error("Input has no audio streams.") |
459 |
| - stream_data = levels.all() |
460 |
| - else: |
461 |
| - stream_data = total_list |
462 |
| - else: |
463 |
| - assert isinstance(s, int) |
464 |
| - stream_data = to_threshold(levels.audio(s), obj["threshold"]) |
465 |
| - |
466 |
| - assert isinstance(obj["minclip"], int) |
467 |
| - assert isinstance(obj["mincut"], int) |
468 |
| - |
469 |
| - mut_remove_small(stream_data, obj["minclip"], replace=1, with_=0) |
470 |
| - mut_remove_small(stream_data, obj["mincut"], replace=0, with_=1) |
471 |
| - |
472 |
| - return stream_data |
473 |
| - |
474 |
| - if method == "motion": |
475 |
| - return to_threshold( |
476 |
| - levels.motion(obj["stream"], obj["blur"], obj["width"]), |
477 |
| - obj["threshold"], |
478 |
| - ) |
479 |
| - |
480 |
| - if method == "subtitle": |
481 |
| - return levels.subtitle( |
482 |
| - obj["pattern"], |
483 |
| - obj["stream"], |
484 |
| - obj["ignore_case"], |
485 |
| - obj["max_count"], |
486 |
| - ) |
487 |
| - except LevelError as e: |
488 |
| - if strict: |
489 |
| - log.error(e) |
490 |
| - |
491 |
| - return levels.all() |
492 |
| - raise ValueError("Unreachable") |
0 commit comments