Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
botbahlul authored Jun 5, 2023
1 parent fee86ca commit a2bb967
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions win/autosrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pathlib import Path
import shlex

VERSION = "1.3.3"
VERSION = "1.3.4"


#======================================================== ffmpeg_progress_yield ========================================================#
Expand Down Expand Up @@ -1715,6 +1715,29 @@ def __call__(self, media_filepath):
return


def has_subtitles(media_filepath):
if "\\" in media_filepath:
media_filepath = media_filepath.replace("\\", "/")

ffmpeg_cmd = [
"ffmpeg",
"-y",
"-i", media_filepath,
"-map", "0:s:0",
"-f", "srt",
"-"
]

result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True)
#print(result.stdout)
#print(result.stderr)

if result.stdout:
return True # Subtitles detected
else:
return False # No subtitles detected


def show_progress(media_filepath, progress):
global pbar
pbar.update(progress)
Expand Down Expand Up @@ -1876,9 +1899,10 @@ def main():
rendered_media_filepath = None

for media_filepath in media_filepaths:
if ".rendered." in str(media_filepath):
if has_subtitles(media_filepath):
media_filepaths.remove(media_filepath)


for media_filepath in media_filepaths:
print("Processing {}".format(media_filepath))

Expand Down

0 comments on commit a2bb967

Please sign in to comment.