Skip to content

Commit

Permalink
Improve subdump
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Mar 16, 2024
1 parent 4afbc1e commit f209a8f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions auto_editor/subcommands/subdump.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import sys
from dataclasses import dataclass, field

from auto_editor.utils.log import Log

import av
from av.subtitles.subtitle import SubtitleSet


def main(sys_args: list[str] = sys.argv[1:]) -> None:
for i, input_file in enumerate(sys_args):
with av.open(input_file) as container:
for s in range(len(container.streams.subtitles)):
print(f"file: {input_file} ({s})")
print(f"file: {input_file} ({s}:{container.streams.subtitles[s].name})")
for packet in container.demux(subtitles=s):
for item in packet.decode():
if type(item) is av.subtitles.subtitle.SubtitleSet and item:
if type(item) is SubtitleSet and item:
if item[0].type == b"ass":
print(item[0].ass.decode("utf-8"))
else:
elif item[0].type == b"text":
print(item[0].text)
print("------")



if __name__ == "__main__":
main()

0 comments on commit f209a8f

Please sign in to comment.