【发布时间】:2021-12-01 00:19:08
【问题描述】:
我想制作一个简单的编辑器来改变字幕时间。 WebVTT 的字幕是由这样的块组成的:
1
00:02:15.000 --> 00:02:20.000
- Hello World!
如您所见,字幕有时会出现,有时会消失。这个时间也可以点击跳转到视频文件的那个特定点。
现在我想创建一个简单的应用程序,可以将这些时间在时域中向左或向右移动给定的数量。存储这些时间点以便于计算和更改的最佳方式是什么?
例如:
struct SubtitleElement {
std::chrono< ?????? > begin; // What is a good candidate here?
std::chrono< ?????? > end; // What is a good candidate here?
std::string text;
}
稍后我想要对这些元素进行操作的函数。例如:
void shiftTime(SubtitleElement element, int millisecs) {
// reduce begin and end of the element by millisecs
}
DURATION getDuration(SubtitleElement& element) {
//return end - begin
}
DURATION totalDuration(vector<SubtitleElement> elements) {
// sum all the durations of the elements in vector
}
那么最干净、最现代的方法是什么?同样重要的是,将字符串“hh:mm:ss:ZZZ”转换为该成员很容易。请注意,我认为 hh 可以远远超过 24,因为它的时间量,而不是一天中的时间!例如。一个vido文件可以长达120小时!!
【问题讨论】: