这个问题与@ SuperUser 的另一个问题有关。
我想下载TED Talks和相应的字幕以供离线观看,例如让我们以Richard St. John的简短演讲为例,高分辨率视频下载 URL 如下:
相应的 JSON 编码英文字幕可以在以下位置下载:
这是实际字幕开头的一个例外:
{
"captions": [{
"content": "This is really a two hour presentation I give to high school students,",
"startTime": 0,
"duration": 3000,
"startOfParagraph": false
}, {
"content": "cut down to three minutes.",
"startTime": 3000,
"duration": 1000,
"startOfParagraph": false
}, {
"content": "And it all started one day on a plane, on my way to TED,",
"startTime": 4000,
"duration": 3000,
"startOfParagraph": false
}, {
"content": "seven years ago."
从字幕的末尾开始:
{
"content": "Or failing that, do the eight things -- and trust me,",
"startTime": 177000,
"duration": 3000,
"startOfParagraph": false
}, {
"content": "these are the big eight things that lead to success.",
"startTime": 180000,
"duration": 4000,
"startOfParagraph": false
}, {
"content": "Thank you TED-sters for all your interviews!",
"startTime": 184000,
"duration": 2000,
"startOfParagraph": false
}]
}
我想编写一个应用程序来自动下载视频的高分辨率版本和所有可用的字幕,但我真的很难,因为我必须将字幕转换为(VLC 或任何其他像样的视频播放器)兼容格式(.srt 或 .sub 是我的首选),我不知道 JSON 文件的startTime
和duration
键代表什么。
到目前为止我所知道的是:
- 下载的视频时长为3 分 30 秒,帧率为29 FPS = 6090 帧。
startTime
从 0 开始,aduration
为 3000 = 3000startTime
以 184000 结束,aduration
为 2000 = 186000
还可能值得注意以下 Javascript 片段:
introDuration:16500,
adDuration:4000,
postAdDuration:2000,
所以我的问题是,我应该应用什么逻辑将值转换startTime
为duration
.srt 兼容格式:
1
00:01:30,200 --> 00:01:32,201
MEGA DENG COOPER MINE, INDIA
2
00:01:37,764 --> 00:01:39,039
Watch out, watch out!
或.sub 兼容格式:
{FRAME_FROM}{FRAME_TO}This is really a two hour presentation I give to high school students,
{FRAME_FROM}{FRAME_TO}cut down to three minutes.
谁能帮我解决这个问题?
Ninh Bui 搞定了,公式如下:
introDuration - adDuration + startTime ... introDuration - adDuration + startTime + duration
这种方法允许我通过两种方式直接转换为 .srt 格式(无需知道长度和 FPS):
00:00:12,500 --> 00:00:15,500
This is really a two hour presentation I give to high school students,
00:00:15,500 --> 00:00:16,500
cut down to three minutes.
和:
00:00:00,16500 --> 00:00:00,19500
And it all started one day on a plane, on my way to TED,
00:00:00,19500 --> 00:00:00,20500
seven years ago.