VideoHelp Forum
+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. Hi everybody

    I have been reading and learning a lot on this forum, but this time I need help!

    After ripping a dvd I noticed it has a dual language sub/idx which I converted to srt.
    Now I want to split this file so I have one subtitle file for both languages.

    Found this post with similar problem
    Code:
    https://forum.videohelp.com/threads/388522-Separate-dual-language-subtitle-ass
    I tried the offered solution
    The Japanese seems to be limited to lines using the "PP-OP1-RO" or "PP-ED1-RO" styles. Just delete those. E.g. in Aegisub
    But this didn't work for me. Probably because the subtitles have a different style...

    If someone knows how I can solve this I would very much appreciate it!
    Subtitle file is attached.

    Kind regards
    Image Attached Files
    Quote Quote  
  2. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    FR.srt
    EN.srt

    There must be a smarter way than this but I don't know it.

    Code:
    import re
    
    
    def parse_srt_file(file_path):
        with open(file_path, 'r', encoding='utf-8-sig') as file:
            srt_content = file.read()
    
        subtitle_blocks = re.split(r'\n\n', srt_content)
        subtitles = []
    
        for block in subtitle_blocks:
            lines = block.strip().split('\n')
            index = int(lines[0])
            time_interval = lines[1]
    
            dialogue_content = tuple(lines[2:])
            subtitles.append((index, time_interval, dialogue_content))
        return subtitles
    
    
    def process_and_write_subtitles(subtitles_list):
        with open('FR.srt', 'w', encoding='utf-8') as fr_file, open('EN.srt', 'w', encoding='utf-8') as en_file:
            for index, time_interval, dialogue_content in subtitles_list:
                fr_file.write(f"{index}\n{time_interval}\n{dialogue_content[0]}\n\n")
                en_file.write(f"{index}\n{time_interval}\n{dialogue_content[len(dialogue_content) // 2]}\n\n")
    
    
    process_and_write_subtitles(parse_srt_file('FR-ENG.srt'))
    Quote Quote  
  3. Originally Posted by 2nHxWW6GkN1l916N3ayz8HQoi View Post

    There must be a smarter way than this but I don't know it.
    Damn this is amazing! Thank you very much, what program did you use to execute this command?
    Quote Quote  
  4. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Originally Posted by vgallotti View Post
    Damn this is amazing! Thank you very much, what program did you use to execute this command?
    That's a Python script. You execute it using Python. You shouldn't bother with it though. I just added it to prove that it can be done. The script may fail for other cases since I've written it only using your fr-eng srt as a reference. I added the split subtitles as attachments.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!