feat: support vtt in sync and fmt

This commit is contained in:
CDN 2025-04-23 15:29:27 +08:00
parent a6284897c8
commit 2fa12dbcde
Signed by: CDN
GPG key ID: 0C656827F9F80080
4 changed files with 122 additions and 1 deletions

View file

@ -107,6 +107,7 @@ sub-cli sync <source> <target>
Currently, synchronization only works between files of the same format:
- SRT to SRT
- LRC to LRC
- VTT to VTT
### Behavior Details
@ -127,6 +128,16 @@ Currently, synchronization only works between files of the same format:
- **Preserved from target**: All subtitle text content.
- **Modified in target**: Timestamps are updated and entry numbers are standardized (sequential from 1).
#### For VTT Files:
- **When entry counts match**: Both start and end times from the source are directly applied to the target entries.
- **When entry counts differ**: A scaled approach is used, similar to SRT synchronization:
- Start times are taken from proportionally matched source entries
- End times are calculated based on source entry durations
- The timing relationship between entries is preserved
- **Preserved from target**: All subtitle text content, formatting, cue settings, and styling.
- **Modified in target**: Timestamps are updated and cue identifiers are standardized (sequential from 1).
### Edge Cases
- If the source file has no timing information, the target remains unchanged.
@ -142,6 +153,9 @@ sub-cli sync reference.srt target.srt
# Synchronize an LRC file using another LRC file as reference
sub-cli sync reference.lrc target.lrc
# Synchronize a VTT file using another VTT file as reference
sub-cli sync reference.vtt target.vtt
```
## fmt

View file

@ -107,6 +107,7 @@ sub-cli sync <源文件> <目标文件>
目前,同步仅适用于相同格式的文件之间:
- SRT到SRT
- LRC到LRC
- VTT到VTT
### 行为详情
@ -127,6 +128,16 @@ sub-cli sync <源文件> <目标文件>
- **从目标保留**: 所有字幕文本内容。
- **在目标中修改**: 更新时间戳并标准化条目编号从1开始顺序编号
#### 对于VTT文件
- **当条目数匹配时**: 源的开始和结束时间直接应用于目标条目。
- **当条目数不同时**: 使用缩放方法:
- 开始时间取自按比例匹配的源条目
- 结束时间根据源条目时长计算
- 保持条目之间的时间关系
- **从目标保留**: 所有字幕文本内容和样式信息。
- **在目标中修改**: 更新时间戳并标准化提示标识符。
### 边缘情况
- 如果源文件没有时间信息,目标保持不变。
@ -142,6 +153,9 @@ sub-cli sync reference.srt target.srt
# 使用另一个LRC文件作为参考来同步LRC文件
sub-cli sync reference.lrc target.lrc
# 使用另一个VTT文件作为参考来同步VTT文件
sub-cli sync reference.vtt target.vtt
```
## fmt