Study hard and make progress every day!

2017-07-17
如何给本地视频生成字幕

场景

适合如下场景:

  • 视频本身不带字幕
  • 直接看英文视频比较吃力

此时可以使用autosub这个工具来根据视频中的声音来生成对应的字幕,虽然生成的字幕并不总是那么正确,但当做参考还是不错的。

autosub简介

autosub是一款由python 2编写的通过Google Web Speech API和FFmpeg来获取视频subtitle的软件

Github地址: https://github.com/agermanidis/autosub

Github上的Usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ autosub -h
usage: autosub [-h] [-C CONCURRENCY] [-o OUTPUT] [-F FORMAT] [-S SRC_LANGUAGE]
[-D DST_LANGUAGE] [-K API_KEY] [--list-formats]
[--list-languages]
[source_path]

positional arguments:
source_path Path to the video or audio file to subtitle

optional arguments:
-h, --help show this help message and exit
-C CONCURRENCY, --concurrency CONCURRENCY
Number of concurrent API requests to make
-o OUTPUT, --output OUTPUT
Output path for subtitles (by default, subtitles are
saved in the same directory and name as the source
path)
-F FORMAT, --format FORMAT
Destination subtitle format
-S SRC_LANGUAGE, --src-language SRC_LANGUAGE
Language spoken in source file
-D DST_LANGUAGE, --dst-language DST_LANGUAGE
Desired language for the subtitles
-K API_KEY, --api-key API_KEY
The Google Translate API key to be used. (Required for
subtitle translation)
--list-formats List all available subtitle formats
--list-languages List all available source/destination languages
阅读此文