Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closed captions #363

Open
The-Bart-The opened this issue Nov 30, 2023 · 1 comment
Open

closed captions #363

The-Bart-The opened this issue Nov 30, 2023 · 1 comment

Comments

@The-Bart-The
Copy link

Compose a Python script that converts a Sonic Scenarist Closed Captions file (.scc) to an Advanced SubStation Alpha file (.ass)

Copy link
Member

Sure! Here's a simple Python script that can convert a Sonic Scenarist Closed Captions file (.scc) to an Advanced SubStation Alpha file (.ass):

def convert_scc_to_ass(scc_file, ass_file):
    with open(scc_file, 'r') as scc:
        lines = scc.readlines()
    
    ass_lines = []
    for line in lines:
        if line.startswith('Scenarist_SCC V1.0'):
            continue  # Skip header
        
        if line.startswith('00:'):
            time, caption = line.replace('\n', '').split(' ', 1)
            start_time, end_time = time.split(':')[-1], time.split(':')[-1]
            start_time = f'{start_time[:-2]}.{start_time[-2:]}'  # Convert to ASS time format
            end_time = f'{end_time[:-2]}.{end_time[-2:]}'  # Convert to ASS time format
            ass_lines.append(f'Dialogue: 0,{start_time},{end_time},Default,,0,0,0,,{caption}\n')
    
    with open(ass_file, 'w') as ass:
        ass.writelines(ass_lines)

# Usage example
convert_scc_to_ass('input.scc', 'output.ass')

Make sure you replace 'input.scc' and 'output.ass' with the actual paths to your input SCC file and the desired output ASS file, respectively.

You can run this script by saving it to a Python file (e.g., scc_to_ass_converter.py) and executing it using a Python interpreter:

$ python scc_to_ass_converter.py

Hope this helps! Let me know if you have any further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants