This python script identifies all movies with mp4 extension and, if they have subtitles in srt format, converts the subtitle encoding to utf-8 (without this conversion you will get error message) and starts building the movie with the subtitle embedded.
for filename in glob.glob("*.mp4"):
print(str(filename))
if 'wsubs' not in filename:
for legenda in glob.glob(filename.replace(".mp4",".srt")):
try:
with open(legenda, 'r') as arquivo_orig:
conteudo = arquivo_orig.read()
with open(legenda, 'w', encoding='utf-8') as novo_arquivo:
novo_arquivo.write(conteudo)
except Exception as e:
print("Já codificado")
print(str(legenda))
os.system('ffmpeg -i "' + str(filename) + '" -vf subtitles="' + str(legenda) + '" -maxrate 2000000 -crf 20 "' + str(filename.replace('.mp4','-wsubs.mp4')) + '"')
The end result will be a subtitled movie with the expression "wsubs" at the end of the name. The original files will be preserved.