FFMpeg 将 .srt 文件作为 WebVTT 嵌入到 hls 流播放列表中
FFMpeg embedding .srt file into hls stream playlist as WebVTT
我有一个 srt 字幕文件,如下所示。
1
00:00:06,840 --> 00:00:10,320
once long ago in the deep blue below
2
00:00:12,360 --> 00:00:14,370
Don't be silly, Gran Mother
3
00:00:14,870 --> 00:00:16,700
Everybody knows there's no such thing as
4
00:00:16,700 --> 00:00:17,200
Mermaids
5
00:00:17,620 --> 00:00:21,570
You wouldn't say that if you has meet one. You've meet a Mermaid
6
00:00:24,250 --> 00:00:25,180
This just came in
7
00:00:25,480 --> 00:00:26,630
I wanted to take priority
8
00:00:27,180 --> 00:00:28,500
And we followed stories like this before
9
00:00:28,640 --> 00:00:31,620
Would witches working mummies. No not like this
10
00:00:31,630 --> 00:00:33,190
Hundreds of people are testifying
11
00:00:33,370 --> 00:00:34,600
Welcome to Mississippi
12
00:00:42,390 --> 00:00:47,270
There's a powerful magic in you the spirit of the ocean
13
00:00:47,690 --> 00:00:53,940
Let me introduce you to your dreams, The Little Mermaid, off the Mississippi
14
00:01:01,880 --> 00:01:03,580
She was so beautiful
15
00:01:04,040 --> 00:01:05,270
And I know she was real
16
00:01:07,850 --> 00:01:08,550
I'm skeptical
17
00:01:13,460 --> 00:01:14,410
You shouldn't be here
18
00:01:17,560 --> 00:01:24,130
Mermaids do not exist
19
00:01:31,420 --> 00:01:34,300
Look isn't it beautiful? Sorry I have to go.
20
00:01:35,340 --> 00:01:48,570
Elizabeth, How can this be? It's Lock he knows i'm here he summoned me.
21
00:01:48,570 --> 00:01:50,570
We have to save here.
22
00:02:03,570 --> 00:02:05,570
Here soul is mine
23
00:02:05,570 --> 00:02:06,570
Take it
24
00:02:10,570 --> 00:02:12,570
It's the only way
25
00:02:15,000 --> 00:02:17,570
I believe
26
00:02:23,000 --> 00:02:25,570
Mississippi has always been magic
27
00:02:36,000 --> 00:02:38,000
Elizabeth please
如果我使用 AWS Media convert 将其添加到我的播放列表,它会输出以下内容。
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:300
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:170,
masterCaptionsEnglish/English.vtt
#EXT-X-ENDLIST
WebVTT 文件如下所示。
WEBVTT #Elemental Media Engine(TM) 2.16.0.602399
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:191970
00:00:06.840 --> 00:00:10.320
once long ago in the deep blue below
00:00:12.360 --> 00:00:14.370
Don't be silly, Gran Mother
00:00:14.870 --> 00:00:16.700
Everybody knows there's no such thing as
00:00:16.700 --> 00:00:17.200
Mermaids
00:00:17.620 --> 00:00:21.570
You wouldn't say that if you has meet one. You've meet a Mermaid
00:00:24.250 --> 00:00:25.180
This just came in
00:00:25.480 --> 00:00:26.630
I wanted to take priority
00:00:27.180 --> 00:00:28.500
And we followed stories like this before
00:00:28.640 --> 00:00:31.620
Would witches working mummies. No not like this
00:00:31.630 --> 00:00:33.190
Hundreds of people are testifying
00:00:33.370 --> 00:00:34.600
Welcome to Mississippi
00:00:42.390 --> 00:00:47.270
There's a powerful magic in you the spirit of the ocean
00:00:47.690 --> 00:00:53.940
Let me introduce you to your dreams, The Little Mermaid, off the Mississippi
00:01:01.880 --> 00:01:03.580
She was so beautiful
00:01:04.040 --> 00:01:05.270
And I know she was real
00:01:07.850 --> 00:01:08.550
I'm skeptical
00:01:13.460 --> 00:01:14.410
You shouldn't be here
00:01:17.560 --> 00:01:24.130
Mermaids do not exist
00:01:31.420 --> 00:01:34.300
Look isn't it beautiful? Sorry I have to go.
00:01:35.340 --> 00:01:48.570
Elizabeth, How can this be? It's Lock he knows i'm here he summoned me.
00:01:48.570 --> 00:01:50.570
We have to save here.
00:02:03.570 --> 00:02:05.570
Here soul is mine
00:02:05.570 --> 00:02:06.570
Take it
00:02:10.570 --> 00:02:12.570
It's the only way
00:02:15.000 --> 00:02:17.570
I believe
00:02:23.000 --> 00:02:25.570
Mississippi has always been magic
00:02:36.000 --> 00:02:38.000
Elizabeth please
我正在尝试用 FFMpeg 复制它。我试过以下命令。
ffmpeg -i little-mermaid.mov -i little-mermaid.srt -c copy -c:s webvtt -start_number 0 -hls_time 10000 -f hls mermaid/Eng/master.m3u8
这会创建一个 WebVTT 文件,但它完全错误且不同步。见下文。
所有的时间都变了,它从每个部分中删除了前两位数字。
WEBVTT
00:06.882 --> 00:10.362
once long ago in the deep blue below
00:12.402 --> 00:14.412
Don't be silly, Gran Mother
00:14.912 --> 00:16.742
Everybody knows there's no such thing as
00:16.742 --> 00:17.242
Mermaids
00:00:17.620 -- 00:00:21.570
You wouldn't say that if you has meet one. You've meet a Mermaid
00:24.292 --> 00:25.222
This just came in
00:25.522 --> 00:26.672
I wanted to take priority
00:27.222 --> 00:28.542
And we followed stories like this before
00:28.682 --> 00:31.662
Would witches working mummies. No not like this
00:31.672 --> 00:33.232
Hundreds of people are testifying
00:33.412 --> 00:34.642
Welcome to Mississippi
00:42.432 --> 00:47.312
There's a powerful magic in you the spirit of the ocean
00:47.732 --> 00:53.982
Let me introduce you to your dreams, The Little Mermaid, off the Mississippi
01:01.922 --> 01:03.622
She was so beautiful
01:04.082 --> 01:05.312
And I know she was real
01:07.892 --> 01:08.592
I'm skeptical
01:13.502 --> 01:14.452
You shouldn't be here
01:17.602 --> 01:24.172
Mermaids do not exist
01:31.462 --> 01:34.342
Look isn't it beautiful? Sorry I have to go.
01:35.382 --> 01:48.612
Elizabeth, How can this be? It's Lock he knows i'm here he summoned me.
01:48.612 --> 01:50.612
We have to save here.
02:03.612 --> 02:05.612
Here soul is mine
02:05.612 --> 02:06.612
Take it
02:10.612 --> 02:12.612
It's the only way
02:15.042 --> 02:17.612
I believe
02:23.042 --> 02:25.612
Mississippi has always been magic
02:36.042 --> 02:38.042
Elizabeth please
我正在尝试确定将 .srt 转换为 WebVTT 并在不使用 FFMPEG 编码的情况下使用该文件是否有意义只需创建一个带有 -hls_flag single_file 的 .m3u8 文件指向它但不确定这可能会导致什么实现。
任何人都可以建议我该怎么做或哪里可能出错吗?
如果有人想 运行 上面的 FFMPEG 命令进行测试,这是我正在使用的视频文件。
http://www.hd-trailers.net/movie/the-little-mermaid/
谢谢
这里真的没有错。所有媒体数据都有两个与之关联的时间戳 - 解码时间戳 (dts) 和呈现时间戳 (pts)。对于非视频流,这些通常是相同的。但是由于视频帧可能会参考未来的帧用于解码目的(B 帧),因此帧按 encoding/decoding 顺序存储,而不是显示顺序。所以,dts可以早于pts。在你的视频中,是这样的,第一个视频帧的pts为0.000000s
,dts为-0.041708s
。由于 MPEG-TS 不存储负时间戳,所有时间戳都向前偏移 0.041708s
,包括字幕。同步不会因此而中断。
我有一个 srt 字幕文件,如下所示。
1
00:00:06,840 --> 00:00:10,320
once long ago in the deep blue below
2
00:00:12,360 --> 00:00:14,370
Don't be silly, Gran Mother
3
00:00:14,870 --> 00:00:16,700
Everybody knows there's no such thing as
4
00:00:16,700 --> 00:00:17,200
Mermaids
5
00:00:17,620 --> 00:00:21,570
You wouldn't say that if you has meet one. You've meet a Mermaid
6
00:00:24,250 --> 00:00:25,180
This just came in
7
00:00:25,480 --> 00:00:26,630
I wanted to take priority
8
00:00:27,180 --> 00:00:28,500
And we followed stories like this before
9
00:00:28,640 --> 00:00:31,620
Would witches working mummies. No not like this
10
00:00:31,630 --> 00:00:33,190
Hundreds of people are testifying
11
00:00:33,370 --> 00:00:34,600
Welcome to Mississippi
12
00:00:42,390 --> 00:00:47,270
There's a powerful magic in you the spirit of the ocean
13
00:00:47,690 --> 00:00:53,940
Let me introduce you to your dreams, The Little Mermaid, off the Mississippi
14
00:01:01,880 --> 00:01:03,580
She was so beautiful
15
00:01:04,040 --> 00:01:05,270
And I know she was real
16
00:01:07,850 --> 00:01:08,550
I'm skeptical
17
00:01:13,460 --> 00:01:14,410
You shouldn't be here
18
00:01:17,560 --> 00:01:24,130
Mermaids do not exist
19
00:01:31,420 --> 00:01:34,300
Look isn't it beautiful? Sorry I have to go.
20
00:01:35,340 --> 00:01:48,570
Elizabeth, How can this be? It's Lock he knows i'm here he summoned me.
21
00:01:48,570 --> 00:01:50,570
We have to save here.
22
00:02:03,570 --> 00:02:05,570
Here soul is mine
23
00:02:05,570 --> 00:02:06,570
Take it
24
00:02:10,570 --> 00:02:12,570
It's the only way
25
00:02:15,000 --> 00:02:17,570
I believe
26
00:02:23,000 --> 00:02:25,570
Mississippi has always been magic
27
00:02:36,000 --> 00:02:38,000
Elizabeth please
如果我使用 AWS Media convert 将其添加到我的播放列表,它会输出以下内容。
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:300
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:170,
masterCaptionsEnglish/English.vtt
#EXT-X-ENDLIST
WebVTT 文件如下所示。
WEBVTT #Elemental Media Engine(TM) 2.16.0.602399
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:191970
00:00:06.840 --> 00:00:10.320
once long ago in the deep blue below
00:00:12.360 --> 00:00:14.370
Don't be silly, Gran Mother
00:00:14.870 --> 00:00:16.700
Everybody knows there's no such thing as
00:00:16.700 --> 00:00:17.200
Mermaids
00:00:17.620 --> 00:00:21.570
You wouldn't say that if you has meet one. You've meet a Mermaid
00:00:24.250 --> 00:00:25.180
This just came in
00:00:25.480 --> 00:00:26.630
I wanted to take priority
00:00:27.180 --> 00:00:28.500
And we followed stories like this before
00:00:28.640 --> 00:00:31.620
Would witches working mummies. No not like this
00:00:31.630 --> 00:00:33.190
Hundreds of people are testifying
00:00:33.370 --> 00:00:34.600
Welcome to Mississippi
00:00:42.390 --> 00:00:47.270
There's a powerful magic in you the spirit of the ocean
00:00:47.690 --> 00:00:53.940
Let me introduce you to your dreams, The Little Mermaid, off the Mississippi
00:01:01.880 --> 00:01:03.580
She was so beautiful
00:01:04.040 --> 00:01:05.270
And I know she was real
00:01:07.850 --> 00:01:08.550
I'm skeptical
00:01:13.460 --> 00:01:14.410
You shouldn't be here
00:01:17.560 --> 00:01:24.130
Mermaids do not exist
00:01:31.420 --> 00:01:34.300
Look isn't it beautiful? Sorry I have to go.
00:01:35.340 --> 00:01:48.570
Elizabeth, How can this be? It's Lock he knows i'm here he summoned me.
00:01:48.570 --> 00:01:50.570
We have to save here.
00:02:03.570 --> 00:02:05.570
Here soul is mine
00:02:05.570 --> 00:02:06.570
Take it
00:02:10.570 --> 00:02:12.570
It's the only way
00:02:15.000 --> 00:02:17.570
I believe
00:02:23.000 --> 00:02:25.570
Mississippi has always been magic
00:02:36.000 --> 00:02:38.000
Elizabeth please
我正在尝试用 FFMpeg 复制它。我试过以下命令。
ffmpeg -i little-mermaid.mov -i little-mermaid.srt -c copy -c:s webvtt -start_number 0 -hls_time 10000 -f hls mermaid/Eng/master.m3u8
这会创建一个 WebVTT 文件,但它完全错误且不同步。见下文。
所有的时间都变了,它从每个部分中删除了前两位数字。
WEBVTT
00:06.882 --> 00:10.362
once long ago in the deep blue below
00:12.402 --> 00:14.412
Don't be silly, Gran Mother
00:14.912 --> 00:16.742
Everybody knows there's no such thing as
00:16.742 --> 00:17.242
Mermaids
00:00:17.620 -- 00:00:21.570
You wouldn't say that if you has meet one. You've meet a Mermaid
00:24.292 --> 00:25.222
This just came in
00:25.522 --> 00:26.672
I wanted to take priority
00:27.222 --> 00:28.542
And we followed stories like this before
00:28.682 --> 00:31.662
Would witches working mummies. No not like this
00:31.672 --> 00:33.232
Hundreds of people are testifying
00:33.412 --> 00:34.642
Welcome to Mississippi
00:42.432 --> 00:47.312
There's a powerful magic in you the spirit of the ocean
00:47.732 --> 00:53.982
Let me introduce you to your dreams, The Little Mermaid, off the Mississippi
01:01.922 --> 01:03.622
She was so beautiful
01:04.082 --> 01:05.312
And I know she was real
01:07.892 --> 01:08.592
I'm skeptical
01:13.502 --> 01:14.452
You shouldn't be here
01:17.602 --> 01:24.172
Mermaids do not exist
01:31.462 --> 01:34.342
Look isn't it beautiful? Sorry I have to go.
01:35.382 --> 01:48.612
Elizabeth, How can this be? It's Lock he knows i'm here he summoned me.
01:48.612 --> 01:50.612
We have to save here.
02:03.612 --> 02:05.612
Here soul is mine
02:05.612 --> 02:06.612
Take it
02:10.612 --> 02:12.612
It's the only way
02:15.042 --> 02:17.612
I believe
02:23.042 --> 02:25.612
Mississippi has always been magic
02:36.042 --> 02:38.042
Elizabeth please
我正在尝试确定将 .srt 转换为 WebVTT 并在不使用 FFMPEG 编码的情况下使用该文件是否有意义只需创建一个带有 -hls_flag single_file 的 .m3u8 文件指向它但不确定这可能会导致什么实现。
任何人都可以建议我该怎么做或哪里可能出错吗?
如果有人想 运行 上面的 FFMPEG 命令进行测试,这是我正在使用的视频文件。
http://www.hd-trailers.net/movie/the-little-mermaid/
谢谢
这里真的没有错。所有媒体数据都有两个与之关联的时间戳 - 解码时间戳 (dts) 和呈现时间戳 (pts)。对于非视频流,这些通常是相同的。但是由于视频帧可能会参考未来的帧用于解码目的(B 帧),因此帧按 encoding/decoding 顺序存储,而不是显示顺序。所以,dts可以早于pts。在你的视频中,是这样的,第一个视频帧的pts为0.000000s
,dts为-0.041708s
。由于 MPEG-TS 不存储负时间戳,所有时间戳都向前偏移 0.041708s
,包括字幕。同步不会因此而中断。