我正在使用以下命令从视频文件中提取字幕,并将其另存为vtt
.
ffmpeg -i video.mkv -map 0:s:0 subs.vtt 2>&1
Run Code Online (Sandbox Code Playgroud)
它正在工作并输出字幕文件。问题在于 RTL(从右到左)语言(希伯来语、阿拉伯语等)。标点符号放错了位置。
为了您的方便,我将向您展示正在发生的事情的英文示例:
输入文本:
Is he alive?
-I don't know.
Run Code Online (Sandbox Code Playgroud)
输出文本:
?Is he alive
.I don't know-
Run Code Online (Sandbox Code Playgroud)
如果你想要希伯来语原文,它是:
输入文本:
??? ???
-??? ?? ????.
Run Code Online (Sandbox Code Playgroud)
输出文本:
???? ??
.??? ?? ????-
Run Code Online (Sandbox Code Playgroud)
如您所见,末尾的标点符号指向开头,反之亦然。我怎样才能避免这种行为?
我的目标是在单独的文件中下载带有自动生成字幕的 YouTube 视频,例如.vtt
、.srt
等。
我目前正在努力实现这一目标youtube-dl
但如果需要,我愿意接受其他解决方案。
当我运行以下命令时,它将视频下载为.mp4
(这很好)和一个单独的.vtt
文件,但.vtt
似乎不知何故搞砸了,并立即显示整个剪辑的所有文本,而不是指定的时间。
我正在运行的命令:
youtube-dl --write-auto-sub https://www.youtube.com/watch?v=Roc89oOZOF4&list=PLJBo3iyb1U0eNNN4Dij3N-d0rCJpMyAKQ&index=45
Run Code Online (Sandbox Code Playgroud)
下载此 .vtt:
WEBVTT
Kind: captions
Language: en
00:00:05.960 --> 00:00:08.290 align:start position:0%
thank <00:00:06.003><c>you </c><00:00:06.046><c>ah </c><00:00:06.089><c>crap </c><00:00:06.132><c>well </c><00:00:06.175><c>looks </c><00:00:06.218><c>like </c><00:00:06.261><c>the </c><00:00:06.304><c>good </c><00:00:06.347><c>Lord </c><00:00:06.390><c>just </c><00:00:06.433><c>sent </c><00:00:06.476><c>me </c><00:00:06.519><c>a </c><00:00:06.562><c>conversation </c><00:00:06.605><c>starter </c><00:00:06.648><c>come </c><00:00:06.691><c>here </c><00:00:06.734><c>Jesse </c><00:00:06.777><c>come </c><00:00:06.820><c>get </c><00:00:06.863><c>the </c><00:00:06.906><c>ball </c><00:00:06.949><c>hmm</c>
00:00:08.290 --> 00:00:10.549 align:start position:0%
thank you ah crap well looks like the good Lord just sent me a conversation starter come here …
Run Code Online (Sandbox Code Playgroud) 我知道如何在 javascript 中将 .srt 文件格式转换为 webvtt 格式,我想知道如何对 .ass 和 .ssa 字幕文件格式执行相同操作,以便能够解析它们并在不使用文件的情况下即时转换为 webvtt 格式使用 javascript 进行流式传输。
所以我试图在 exoplayer 中显示 .srt 文件中的字幕,但它不起作用。我是否需要使用单独的 SubtitleView 来显示我的字幕?是PlayerView中的subtitleView不够用吗?顺便说一句,我使用 PlayerView。
我使用的exoplayer版本是2.14.0。
addTextOutput 方法。
simpleExoPlayer.addTextOutput(cues -> {
playerView.getSubtitleView().setCues(cues);
playerView.getSubtitleView().setVisibility(View.VISIBLE);
playerView.getSubtitleView().onCues(cues);
assert cues.get(0).text != null;
Log.d("subtitles", cues.get(0).text.toString());
});
Run Code Online (Sandbox Code Playgroud)
我也尝试实施,TextOutput
但这也不起作用。
我的sample.srt 文件的内容:
1
00:00:00,000 --> 00:00:01,500
For www.forom.com
2
00:00:01,500 --> 00:00:02,500
<i>Tonight's the night.</i>
3
00:00:03,000 --> 00:00:15,000
<i>And it's going to happen
again and again --</i>
Run Code Online (Sandbox Code Playgroud)
我用来加载字幕的函数:
1
00:00:00,000 --> 00:00:01,500
For www.forom.com
2
00:00:01,500 --> 00:00:02,500
<i>Tonight's the night.</i>
3
00:00:03,000 --> 00:00:15,000
<i>And it's going to happen
again and …
Run Code Online (Sandbox Code Playgroud) ffmpeg ×2
webvtt ×2
android ×1
exoplayer ×1
exoplayer2.x ×1
javascript ×1
subtitle ×1
youtube-dl ×1