Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active January 3, 2025 01:01
Show Gist options
  • Save thewh1teagle/e1223bff506bda0665f45a9f5c1e309f to your computer and use it in GitHub Desktop.
Save thewh1teagle/e1223bff506bda0665f45a9f5c1e309f to your computer and use it in GitHub Desktop.
Fix subtitles in Hebrew and embed subtitles
import sys
with open(sys.argv[1], 'r', encoding='utf-8') as file:
content = file.read()
lines = []
for line in content.splitlines():
if line.startswith('?') or line.startswith('<i>?'):
line = line.replace('?', '')
line = line.replace('<i>?', '<i>')
lines.append(line)
with open(sys.argv[2], 'w', encoding='utf-8') as file:
for line in lines:
file.write(line + '\n')
print("SRT file has been successfully fixed!")
"""
ffmpeg -i input.mp4 -f srt -i heb-utf8.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s mov_text output.mp4
"""
import sys
with open(sys.argv[1], 'r', encoding='windows-1255') as file:
content = file.read()
with open(sys.argv[2], 'w', encoding='utf-8') as file:
file.write(content)
print("SRT file has been successfully converted to UTF-8!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment