欢迎光临散文网 会员登陆 & 注册

VTT批量转换srt python脚本

2023-04-07 09:23 作者:仿真资料吧  | 我要投稿

(1)脚本

import argparse

import codecs

import math

import os

import re

SUPPORTED_EXTENSIONS = [".xml", ".vtt"]

def leading_zeros(value, digits=2):

    value = "000000" + str(value)

    return value[-digits:]

def convert_time(raw_time):

    if int(raw_time) == 0:

        return "{}:{}:{},{}".format(0, 0, 0, 0)

    ms = '000'

    if len(raw_time) > 4:

        ms = leading_zeros(int(raw_time[:-4]) % 1000, 3)

    time_in_seconds = int(raw_time[:-7]) if len(raw_time) > 7 else 0

    second = leading_zeros(time_in_seconds % 60)

    minute = leading_zeros(int(math.floor(time_in_seconds / 60)) % 60)

    hour = leading_zeros(int(math.floor(time_in_seconds / 3600)))

    return "{}:{}:{},{}".format(hour, minute, second, ms)

(2)双击run.bat即可:

(3)脚本领取:

链接:https://pan.baidu.com/s/1ZhiA3t6DWaY39x4bCh7yzg?pwd=9e0w 

提取码:9e0w 

--来自百度网盘超级会员V6的分享


VTT批量转换srt python脚本的评论 (共 条)

分享到微博请遵守国家法律