texttaglib/vtt.py
def sec2ts(seconds):
    ''' Convert duration in seconds to VTT format (e.g. 01:53:47.262) '''
    try:
        seconds = float(seconds)
        if seconds < 0:
            raise ValueError("Timestamp cannot be smaller than 0")
    except Exception as e:
        raise ValueError("Invalid timestamp ({})".format(seconds)) from e
    min_base = math.floor(seconds / 60)
    ts_hour = math.floor(min_base / 60)
    ts_min = math.floor(min_base % 60)
    ts_sec = math.floor(seconds) % 60
    ts_msec = (seconds - int(seconds)) * 1000
    ts = "{:0>2.0f}:{:0>2.0f}:{:0>2.0f}.{:0>3.0f}".format(ts_hour, ts_min, ts_sec, ts_msec)
    return ts
 Convert duration in seconds to VTT format (e.g. 01:53:47.262) 
Convert duration in seconds to VTT format
Convert duration in seconds to VTT format
def sec2ts(seconds):
    try:
        seconds = float(seconds)
        if seconds < 0:
            raise ValueError("Timestamp cannot be smaller than 0")
    except Exception as e:
        raise ValueError("Invalid timestamp ({})".format(seconds)) from e
    min_base = math.floor(seconds / 60)
    ts_hour = math.floor(min_base / 60)
    ts_min = math.floor(min_base % 60)
    ts_sec = math.floor(seconds) % 60
    ts_msec = (seconds - int(seconds)) * 1000
    ts = "{:0>2.0f}:{:0>2.0f}:{:0>2.0f}.{:0>3.0f}".format(ts_hour, ts_min, ts_sec, ts_msec)
    return ts
def sec2ts ( seconds ) : try : seconds = float ( seconds ) if seconds < 0 : raise ValueError ( "Timestamp cannot be smaller than 0" ) except Exception as e : raise ValueError ( "Invalid timestamp ({})" . format ( seconds ) ) from e min_base = math . floor ( seconds / 60 ) ts_hour = math . floor ( min_base / 60 ) ts_min = math . floor ( min_base % 60 ) ts_sec = math . floor ( seconds ) % 60 ts_msec = ( seconds - int ( seconds ) ) * 1000 ts = "{:0>2.0f}:{:0>2.0f}:{:0>2.0f}.{:0>3.0f}" . format ( ts_hour , ts_min , ts_sec , ts_msec ) return ts
Convert duration in seconds to VTT format (e.g.
Convert duration in seconds to VTT format ( e . g .
''' Convert duration in seconds to VTT format (e.g. 01:53:47.262) '''
seconds