Skip to content

Commit

Permalink
audio #:stream don't allow string literal
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Feb 27, 2024
1 parent c73a9b9 commit d9d7189
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions auto_editor/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
If timebase is 30, 400 ticks to 800 means 13.33 to 26.66 seconds
""".strip(),
"--edit-based-on": """
Evalutes a palet expression that returns a bool-array?. The array is then used for
Evaluates a palet expression that returns a bool-array?. The array is then used for
editing.
Editing Methods:
- audio ; Audio silence/loudness detection
- threshold threshold? : 4%
- stream (or/c nat? 'all "all") : 0
- stream (or/c nat? 'all) : 'all
- mincut nat? : 6
- minclip nat? : 3
; mincut is more significant, there it has a larger default value.
; minclip gets applied first, then mincut
- motion ; Motion detection specialized for noisy real-life videos
- threshold threshold? : 2%
- stream nat? : 0
Expand Down Expand Up @@ -150,10 +153,6 @@
""".strip(),
"--video-bitrate": """
`--video-bitrate` sets the target bitrate for the video encoder. It accepts the same format as `--audio-bitrate` and the special `unset` value is allowed.
""".strip(),
"--silent-threshold": """
Silent threshold is a percentage where 0% represents absolute silence and 100% represents the highest volume in the media file.
Setting the threshold to `0%` will cut only out areas where area is absolutely silence.
""".strip(),
"--margin": """
Default value: 0.2s,0.2s
Expand Down
8 changes: 4 additions & 4 deletions auto_editor/lang/palet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ def edit_all() -> np.ndarray:


def edit_audio(
threshold: float = 0.04, stream: object = "all", mincut: int = 6, minclip: int = 3
threshold: float = 0.04, stream: object = Sym("all"), mincut: int = 6, minclip: int = 3
) -> np.ndarray:
if "@levels" not in env or "@filesetup" not in env:
raise MyError("Can't use `audio` if there's no input media")
Expand All @@ -1480,7 +1480,7 @@ def edit_audio(
strict = env["@filesetup"].strict

stream_data: NDArray[np.bool_] | None = None
if stream == "all" or stream == Sym("all"):
if stream == Sym("all"):
stream_range = range(0, len(src.audios))
else:
assert isinstance(stream, int)
Expand All @@ -1502,7 +1502,7 @@ def edit_audio(

return stream_data

stream = 0 if stream == "all" or stream == Sym("all") else stream
stream = 0 if stream == Sym("all") else stream
return raise_(f"audio stream '{stream}' does not exist") if strict else levels.all()


Expand Down Expand Up @@ -1615,7 +1615,7 @@ def my_eval(env: Env, node: object) -> Any:
"none": Proc("none", edit_none, (0, 0)),
"all/e": Proc("all/e", edit_all, (0, 0)),
"audio": Proc("audio", edit_audio, (0, 4),
is_threshold, orc(is_nat, Sym("all"), "all"), is_nat,
is_threshold, orc(is_nat, Sym("all")), is_nat,
{"threshold": 0, "stream": 1, "minclip": 2, "mincut": 2}
),
"motion": Proc("motion", edit_motion, (0, 4),
Expand Down

0 comments on commit d9d7189

Please sign in to comment.