是否可以从ffmpeg的MP4视频中提取SubRip(SRT)字幕? [英] Is it possible to extract SubRip (SRT) subtitles from an MP4 video with ffmpeg?

查看:6085
本文介绍了是否可以从ffmpeg的MP4视频中提取SubRip(SRT)字幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查过FFMpeg文档和许多论坛,并找出正确的命令行从.MP4视频中提取字幕应如下所示:

I have checked the FFMpeg documentation and many forums and figured out the correct command-line to extract subtitles from an .MP4 video should look like so:

ffmpeg -i video.mp4 -vn -an -codec:s:0 srt out.srt

但是,我收到以下错误,这让我质疑这是否可行:

However, I get the following error, which lends me to question whether this is feasible at all:


错误打开编码器输出流#0:0 - 可能不正确的参数
,如bit_rate,rate,width或height

Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

使用 ffmpeg -codecs ,我可以确认ffmpeg应该能够编码子字幕。

Using ffmpeg -codecs, I can confirm that ffmpeg should be able to encode subrip subtitles.

使用 ffmpeg -i video.mp4 ,我可以看到视频中嵌入了两个字幕轨:

Using ffmpeg -i video.mp4, I can see that there is two subtitle tracks embedded in the video :

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
...
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x572 [SAR 64:45 DAR 256:143], 1341 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 191 kb/s
Stream #0:2(fra): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 191 kb/s
Stream #0:3(eng): Subtitle: dvd_subtitle (mp4s / 0x7334706D)
Stream #0:4(und): Subtitle: mov_text (text / 0x74786574)

编辑

我已经使用评论中显示的简化命令行进行测试,但我仍然收到同样的错误。以下是运行该命令的详细详细输出的链接。我也试图完全禁用生成的输出中的元数据和章节,但仍然产生相同的错误。

I have tested with the simplified command-line shown in the comments but I still get the same error. Here is a link to the detailed verbose output from running the command. I have also tried to completely disable metadata and chapters in the resulting output but that still produces the same error.

推荐答案

我从来没有想到为什么我没有成功:

I enventually figured out why I did not succeed:

如果来自源视频的字幕是以基于文本的表示形式编码的,则指定的命令行将非常正常。但是,从 ffmpeg -i 命令行的输出可以看出,字幕以dvd_subtitle格式编码。

The specified command-line would have been perfectly fine if the subtitles from the source video were encoded in a text-based representation. However, as can be seen in the output to the ffmpeg -i command-line, the subtitles are encoded in the "dvd_subtitle" format.

dvd_subtitle格式存储视频中每个字幕的位图。因此,ffmpeg将无法将位图转换为文本。

The dvd_subtitle format stores bitmaps for each subtitle in the video. Therefore, there is no way ffmpeg would be able to translate the bitmaps into text.

对于此任务,必须使用基于OCR的软件来协助用户其任务是从其位图代码中将每个字幕标识为文本。

For this task, one has to resort to an OCR-based software which assists a user with the task of identifying each subtitle as text from its bitmap représentation.

(源视频中有一个辅助文本的字幕,但我不知道在哪里对于所有意图和目的,这个mov_text字幕似乎是一个存根占位符,可能是从原始DVD转换的工件)

(There is a secondary text-based subtitle in the source video, but I don't know where it came from and is not seen by most popular players. For all intents and purposes, this "mov_text" subtitle seems to be a stub placeholder, probably an artifact of the conversion from the original DVD)

这篇关于是否可以从ffmpeg的MP4视频中提取SubRip(SRT)字幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆