def adjust_subtitle_timing(subtitle_path, output_path):
    """
    Adjusts subtitle timings to start from the beginning of the video.
    """
    with open(subtitle_path, 'r', encoding='utf-8') as file:
        lines = file.readlines()

    time_pattern = re.compile(r'(\d{2}:\d{2}:\d{2},\d{3})')
    first_timestamp = None
    for line in lines:
        time_match = time_pattern.findall(line)
        if time_match:
            first_timestamp = datetime.datetime.strptime(time_match[0], '%H:%M:%S,%f')
            break

    if first_timestamp is None:
        return  # No adjustment needed if no timestamps found

    start_delta = first_timestamp - datetime.datetime.strptime('00:00:00,000', '%H:%M:%S,%f')

    with open(output_path, 'w', encoding='utf-8') as file:
        for line in lines:
            new_line = line
            match = time_pattern.findall(line)
            if match:
                new_times = []
                for time_str in match:
                    original_time = datetime.datetime.strptime(time_str, '%H:%M:%S,%f')
                    new_time = original_time - start_delta
                    new_times.append(new_time.strftime('%H:%M:%S,%f')[:-3])
                new_line = time_pattern.sub(lambda x: new_times.pop(0), line)
            file.write(new_line)
    logging.info(f"Subtitles timings adjusted: {output_path}")

    Adjusts subtitle timings to start from the beginning of the video.
    
subtitler.py