def read_file_tuples(input_file):
    """
    Read an SRT file to (seq, begin, end, text) tuples, where
    begin and end are float timestamps in seconds. Text is
    actually binary since we don't really care about the encoding here

    Args:
        input_file (string): input file name

    Yields:
        generator of tuples (seq, begin, end, text)
    """
    def parse_time(timestamp):
        hours, minutes, secs = timestamp.split(b':')
        return (int(hours)*60 + int(minutes))*60 + float(secs.replace(b',', b'.'))

    def convert_line_ending(data):
        "Convert line endings to UNIX"
        return data.replace(b'\r\n', b'\n').replace(b'\r', b'\n')

    def remove_boms(data):
        "remove UTF BOMs if present"
        BOMS = [b'\xEF\xBB\xBF', b'\xFE\xFF']
        for bom in BOMS:
            if data.startswith(bom):
                data = data[len(bom):]
        return data

    def get_line_blocks(data):
        "combine invalid SRT line blocks with double line breaks"
        last_block = []
        blocks = []
        for line_block in data.split(b'\n\n'):
            line_block = line_block.strip()
            if len(line_block) == 0: continue
            block = line_block.split(b'\n')
            try: int(block[0])
            except:
                last_block.extend(block)
                continue

            blocks.append(block)
            last_block = block
        return blocks

    with open(input_file, 'rb') as f:
        srt_data = f.read()

    srt_data = convert_line_ending(remove_boms(srt_data))

    error = None
    try:
        for block in get_line_blocks(srt_data):
            seq = int(block[0])
            times = block[1]
            begin, _, end = times.partition(b' --> ')
            text = b'\n'.join(block[2:])
            yield(seq, parse_time(begin), parse_time(end), text)
    except Exception as err:
        error = RuntimeError("%s\n\n\tUnable to parse '%s'. Is it a valid SRT file?\n" \
            % (err, input_file))

    if error is not None: raise error