Skip to content

Commit

Permalink
-sn Disable the inclusion of subtitle streams
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Feb 8, 2024
1 parent 6932f08 commit 8a943f7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions auto_editor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ def main_options(parser: ArgumentParser) -> ArgumentParser:
help="Apply audio rendering to all audio tracks. Applied right before rendering the output file.",
)
parser.add_text("Miscellaneous:")
parser.add_argument(
"-sn",
flag=True,
help="Disable the inclusion of subtitle streams in the output file",
)
parser.add_argument(
"--extras",
metavar="CMD",
Expand Down
4 changes: 2 additions & 2 deletions auto_editor/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def edit_media(

if tl is None:
# Extract subtitles in their native format.
if src is not None and len(src.subtitles) > 0:
if src is not None and len(src.subtitles) > 0 and not args.sn:
cmd = ["-i", f"{src.path}", "-hide_banner"]
for s, sub in enumerate(src.subtitles):
cmd.extend(["-map", f"0:s:{s}"])
Expand Down Expand Up @@ -283,7 +283,7 @@ def make_media(tl: v3, output: str) -> None:
sub_output = []
apply_later = False

if ctr.allow_subtitle:
if ctr.allow_subtitle and not args.sn:
sub_output = make_new_subtitles(tl, ffmpeg, temp, log)

if ctr.allow_audio:
Expand Down
6 changes: 4 additions & 2 deletions auto_editor/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def mux_quality_media(
) -> None:
v_tracks = len(visual_output)
a_tracks = len(audio_output)
s_tracks = len(sub_output)
s_tracks = 0 if args.sn else len(sub_output)

cmd = ["-hide_banner", "-y", "-i", f"{src.path}"]

Expand Down Expand Up @@ -192,7 +192,9 @@ def mux_quality_media(
if args.extras is not None:
cmd.extend(args.extras.split(" "))
cmd.extend(["-strict", "-2"]) # Allow experimental codecs.
cmd.extend(["-map", "0:t?"]) # Add input attachments to output.

if not args.sn:
cmd.extend(["-map", "0:t?"]) # Add input attachments to output.

# This was causing a crash for 'example.mp4 multi-track.mov'
# cmd.extend(["-map", "0:d?"])
Expand Down
1 change: 1 addition & 0 deletions auto_editor/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class Args:
video_quality_scale: str = "unset"
scale: float = 1.0
extras: str | None = None
sn: bool = False
no_seek: bool = False
cut_out: list[list[str]] = field(default_factory=list)
add_in: list[list[str]] = field(default_factory=list)
Expand Down

0 comments on commit 8a943f7

Please sign in to comment.