I have file "srt" I want to add alignment for each line
Before
SUB.English.srt
Code:1 00:03:33,680 --> 00:03:35,215 - my car... - what is it doing? 2 00:03:36,549 --> 00:03:38,051 What are you doing? 3 00:03:38,117 --> 00:03:39,953 What are you driving?
after
output.srt
Code:1 00:03:33,680 --> 00:03:35,215 {\an8}- my car... - what is it doing? 2 00:03:36,549 --> 00:03:38,051 {\an8}What are you doing? 3 00:03:38,117 --> 00:03:39,953 {\an8}What are you driving?
All I need only. add alignment Using Python Any suggestions?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 7 of 7
Thread
-
-
This might work, (not tested):
Code:infile = 'orig.srt' outfile = 'output_file.srt' #formatting new line, where {0} gets formatted as original text new_line = '{{\\an8}}{0}\n' with open(outfile, 'w') as out_file: with open(infile) as in_file: rewrite = False for line in in_file: if rewrite: #format new text line out_file.write(new_line.format(line)) else: #just copy line out_file.write(f'{line}\n') if '-->' in line: rewrite = True else: rewrite = False
-
Thanks it works. Is there a solution for empty spaces?
https://forum.videohelp.com/images/imgfiles/v6iYfwG.jpg -
ok, '\n' is a new line for printing. I thought that when reading lines that line variable string does not carry it at the end.
-
I remember that this already happened to me, and simply 're-saving as srt' in 'Subtitle Edit' was corrected ...
責任者-MDX -
Things like that are easier to do in apps that handle subtitles. But he mentioned in his earliest threads that he uses windows batch files to handle more subtitles at once or for some other reasons.
Similar Threads
-
alignment issue in Subtitle Edit 3.4.11
By whitelighter27 in forum SubtitleReplies: 7Last Post: 8th Dec 2021, 07:03 -
how to merge multiple subtitle files in python?
By D.LUFFY in forum ProgrammingReplies: 2Last Post: 7th Nov 2021, 09:24 -
Add Subtitle with HandBrake
By keyboard in forum Newbie / General discussionsReplies: 3Last Post: 23rd Aug 2021, 04:56 -
how do i add subtitle other than englsih in any video converter
By jraju in forum Video Streaming DownloadingReplies: 4Last Post: 4th Jun 2020, 01:10 -
Add a variable to a python file running ffmpeg
By olpdog in forum EditingReplies: 3Last Post: 30th Jun 2019, 18:34