-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |