#6218 The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification:srtfile='

240e:393* Posted at: 22 hours ago

The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification
:srtfile='D:/desktop/2-mp4/zh-cn.srt'
content=''
Traceback (most recent call last):
File "videotrans\task\only_one.py", line 148, in run
File "videotrans\task\_stage_assemble.py", line 26, in assembling
File "videotrans\task\_stage_assemble.py", line 153, in _join_video_audio_srt
File "videotrans\task\_stage_subtitle.py", line 30, in _process_subtitles
File "videotrans\util\_srt_parse.py", line 187, in get_subtitle_from_srt
RuntimeError: The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification
:srtfile='D:/desktop/2-mp4/zh-cn.srt'
content=''

cfg=[TaskCfgVTT]当前工作模式: 翻译视频或音频 单视频模式
原始输入文件名: D:/desktop/2.mp4,
输出结果保存到文件夹: D:/desktop/2-mp4,
临时文件夹: D:/pyvideotrans/tmp/13904/49f7cc35cc
已选 清理已存在
未启用CUDA加速
未选 降噪
语音识别:faster-whisper(内置), model_name: large-v3-turbo, 发音语言: 英语, 断句方式:默认断句
翻译渠道:微软(免费),原始语言:英语,目标语言:简体中文, 未选 发送完整字幕
未选 配音角色,不进行配音
字幕: 嵌入软字幕
代理地址:


=
system:Windows-10-10.0.19045-SP0
version:v4.08
frozen:True
language:zh
root_dir:D:/pyvideotrans

3 Replies

核心原因:目标字幕文件 D:/desktop/2-mp4/zh-cn.srt 是空文件(content=''),导致软件在合成软字幕时无法读取。通常是“字幕翻译”步骤没有生成有效内容,而不是 SRT 格式本身的问题。

请按以下顺序排查:

  1. 打开 D:/desktop/2-mp4/ 文件夹,查看 zh-cn.srten.srt 是否存在及大小。若 en.srt 也为空或不存在,则问题出在语音识别阶段;若 en.srt 有内容而 zh-cn.srt 为空,则问题出在翻译阶段。
  2. 查看日志文件:打开 D:/pyvideotrans/logs/ 目录下最新日期的 .log 文件,滚动到末尾,查找翻译渠道(微软)相关的报错,例如超时、限流、密钥错误等。
  3. 临时更换翻译渠道测试:在“翻译渠道”中改用 Google 或 DeepSeek 等,再执行一次(不要勾选“清理已生成”,或先手动删除输出文件夹中的旧文件)。如果换渠道后正常,说明是微软翻译接口临时故障或限流。
  4. 确认网络畅通:微软翻译在中国大陆一般无需代理,但如果开了代理或使用了不稳定的网络,也可能导致返回空内容。可清空代理地址后再试。

若以上步骤仍无法解决,请提供 logs/ 下最新日志文件末尾约30行内容,以便进一步定位。

请查阅相关文档:


==准备要嵌入的字幕:self.cfg.subtitle_type=2
=
[ERROR] 单视频模式翻译失败The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification
:srtfile='D:/desktop/2-mp4/zh-cn.srt'
content=''
Traceback (most recent call last):
File "videotrans\task\only_one.py", line 148, in run
File "videotrans\task\_stage_assemble.py", line 26, in assembling
File "videotrans\task\_stage_assemble.py", line 153, in _join_video_audio_srt
File "videotrans\task\_stage_subtitle.py", line 30, in _process_subtitles
File "videotrans\util\_srt_parse.py", line 187, in get_subtitle_from_srt
RuntimeError: The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification
:srtfile='D:/desktop/2-mp4/zh-cn.srt'
content=''
[DEBUG] [TransCreate]最终配置信息:self=TransCreate(uuid='49f7cc35cc', proxy_str=None, last_down_time=0, precent=1, hasend=False, should_recogn=True, should_trans=True, should_dubbing=False, should_separate=Fa
......
t': '', 'beam_size': 5, 'best_of': 5, 'temperature': '', 'repetition_penalty': 1.0, 'compression_ratio_threshold': 2.4, 'max_speech_ms': 5000, 'subtitle_srt': 'D:/pyvideotrans/tmp/faster-20260802-09_52_19.srt'}
[DEBUG] 开始加载 faster-whisper模型large-v3-turbo,数据类型:default
[DEBUG] [faster_whisper]加载模型large-v3-turbo: is_cuda=False,_compute_type='default'
[DEBUG] 直接传递完整音频,由faster-whisper内部VAD处理,返回字级时间戳数据
[DEBUG] faster-whisper模式下,对large-v3-turbo模型返回的字级时间戳进行断句
[DEBUG] 断句完毕返回结果
[DEBUG] faster-whisper下已临时保存识别结果到 D:/pyvideotrans/tmp/faster-20260802-09_52_19.srt,防止进程崩溃后永久等待
[DEBUG] [新进程任务 title='Model: large-v3-turbo'] 已返回
[DEBUG] [新进程任务 结束:title='Model: large-v3-turbo'],耗时16.11011028289795s
[DEBUG] 移除无效字幕行
[DEBUG] 修正重叠时间轴
[DEBUG] 开始移除每条字幕末尾标点

[DEBUG] 以纯文本行形式翻译,每次翻译10行,翻译后暂停0.0s
[INFO] Starting call to 'videotrans.translator._tencent.Tencent._item_task', this is the 1st time calling it.
[DEBUG] [腾讯]返回:resp={"TargetText": "(注)(注)\n这是个好主意。", "Source": "ja", "Target": "zh", "RequestId": "11ba1f29-ce05-4202-b477-a41c630dc6ba"}
[DEBUG] 原始行数:2,翻译后行数:2
[DEBUG] 原始语言字幕和目标语言字幕行数一致,均为 source_len=2

[DEBUG]


==准备要嵌入的字幕:self.cfg.subtitle_type=2
=
[ERROR] 单视频模式翻译失败The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification
:srtfile='D:/desktop/2-mp4/zh-cn.srt'
content=''
Traceback (most recent call last):
File "videotrans\task\only_one.py", line 148, in run
File "videotrans\task\_stage_assemble.py", line 26, in assembling
File "videotrans\task\_stage_assemble.py", line 153, in _join_video_audio_srt
File "videotrans\task\_stage_subtitle.py", line 30, in _process_subtitles
File "videotrans\util\_srt_parse.py", line 187, in get_subtitle_from_srt
RuntimeError: The srt subtitles were not read. The file may be empty or the format does not conform to the SRT specification
:srtfile='D:/desktop/2-mp4/zh-cn.srt'
content=''

核心原因:从日志看,语音识别和腾讯翻译均已成功(识别出2条字幕,翻译也返回了2行),但最终 D:/desktop/2-mp4/zh-cn.srt 文件为空。问题不在 SR T格式,而是翻译结果未成功写入该文件,常见原因是旧缓存/空文件残留、翻译缓存干扰,或输出目录写入异常。

请按以下步骤操作:

  1. 彻底清理输出目录:删除 D:/desktop/2-mp4/ 文件夹下的所有文件(尤其 zh-cn.srten.srt)。
  2. 在主界面勾选“清理已生成”(或“清理已存在”),确保不使用旧缓存。
  3. 清除翻译缓存:删除 D:/pyvideotrans/tmp/translate_cache/ 目录下的所有文件,或直接删除整个 translate_cache 文件夹。
  4. 更换翻译渠道:日志显示当前使用的是“腾讯翻译”,且返回了 (注)(注) 这类奇怪内容。建议在“翻译渠道”中改为 Google 或 DeepSeek 等再测试,排除腾讯接口返回异常。
  5. 检查输出目录是否有写入权限,并确认杀毒软件没有拦截 sp.exe 或阻止文件写入。可将输出目录改到新的纯英文路径(如 D:/desktop/out)再试。
  6. 如果仍失败,请提供 logs/ 目录下最新日志文件中“准备要嵌入的字幕”前后更完整的上下文(约30行),以便进一步定位。

请查阅相关文档:

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Dondate via PayPal

Related resource