20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)

20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)
2021/2/24 11:17


1、安装python-3.9.1-amd64.exe
Windows installer (64-bit)    Windows    Recommended    b3fce2ed8bc315ad2bc49eae48a94487    28204528    SIG

https://www.python.org/
https://www.python.org/downloads/
https://www.python.org/downloads/release/python-391/
下载python-2.7.13.amd64.msi并安装。记得加入环境变量!

请注意要添加环境变量!安装完成之后测试一下:
Microsoft Windows [版本 10.0.18363.1316]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\DELL>python
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\Users\DELL>


2、ffmpeg下载:
http://www.ffmpeg.org/download.html
Windows EXE Files

Windows builds by BtbN
Windows builds from gyan.dev
git
Links
https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z
https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z
参考名称:ffmpeg-2020-11-04-git-cfdddec0c8-essentials_build.7z
其它的预编译版本的ffmpeg也应该可以的,但是没有测试!

D:\360极速浏览器下载\ffmpeg-2020-11-04-git-cfdddec0c8-essentials_build\bin


方法一:
此电脑(右键)→属性→高级系统设置→高级→环境变量→

在系统变量的Path变量中加入:
C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\NetSarang\Xshell 7\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\;C:\ProgramData\Anaconda2\ffmpeg\bin;

方法二:
将ffmpeg-2020-11-04-git-cfdddec0c8-essentials_build改名为ffmpeg,放到C:\Windows\System32里


C:\Users\wb491>
C:\Users\wb491>
C:\Users\wb491>ffmpeg -h
ffmpeg version 2020-11-04-git-cfdddec0c8-essentials_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.0 (Rev3, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.101 / 58.112.101
  libavformat    58. 64.100 / 58. 64.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.102 /  7. 88.102
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol
    See man ffmpeg for detailed description of the options.

Print help / information / capabilities:
-L                  show license
-h topic            show help
-? topic            show help
-help topic         show help
--help topic        show help
-version            show version
-buildconf          show build configuration
-formats            show available formats
-muxers             show available muxers
-demuxers           show available demuxers
-devices            show available devices
-codecs             show available codecs
-decoders           show available decoders
-encoders           show available encoders
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats
-colors             show available color names
-sources device     list sources of the input device
-sinks device       list sinks of the output device
-hwaccels           show available HW acceleration methods

Global options (affect whole program instead of just one file):
-loglevel loglevel  set logging level
-v loglevel         set logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  never overwrite output files
-ignore_unknown     Ignore unknown stream types
-filter_threads     number of non-complex filter threads
-filter_complex_threads  number of threads for -filter_complex
-stats              print progress report during encoding
-max_error_rate maximum error rate  ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-bits_per_raw_sample number  set the number of bits per raw sample
-vol volume         change audio volume (256=normal)

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-pre preset         preset name
-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
-t duration         record or transcode "duration" seconds of audio/video
-to time_stop       record or transcode stop time
-fs limit_size      set the limit file size in bytes
-ss time_off        set the start time offset
-sseof time_off     set the start time offset relative to EOF
-seek_timestamp     enable/disable seeking by timestamp with -ss
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-program title=string:st=number...  add program with specified streams
-target type        specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
-apad               audio pad
-frames number      set the number of frames to output
-filter filter_graph  set stream filtergraph
-filter_script filename  read stream filtergraph description from a file
-reinit_filter      reinit filtergraph on input parameter changes
-discard            discard
-disposition        disposition

Video options:
-vframes number     set the number of video frames to output
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number  set the number of bits per raw sample
-vn                 disable video
-vcodec codec       force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
-pass n             select the pass number (1 to 3)
-vf filter_graph    set video filters
-ab bitrate         audio bitrate (please use -b:a)
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

Audio options:
-aframes number     set the number of audio frames to output
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-af filter_graph    set audio filters

Subtitle options:
-s size             set frame size (WxH or abbreviation)
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)
-stag fourcc/tag    force subtitle tag/fourcc
-fix_sub_duration   fix subtitles duration
-canvas_size size   set canvas size (WxH or abbreviation)
-spre preset        set the subtitle options to the indicated preset

C:\Users\wb491>


3、 安装AutoSub:pip install autosub。需要升级pip!
Microsoft Windows [版本 10.0.18363.1316]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\DELL>e:

E:\>
E:\>pip install autosub
Collecting autosub
  Downloading autosub-0.3.12.tar.gz (7.3 kB)
Collecting google-api-python-client>=1.4.2
  Downloading google_api_python_client-1.12.8-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 8.7 kB/s
Collecting requests>=2.3.0
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 16 kB/s
Collecting pysrt>=1.0.1
  Downloading pysrt-1.1.2.tar.gz (104 kB)
     |████████████████████████████████| 104 kB 5.2 kB/s
Collecting progressbar>=2.3
  Downloading progressbar-2.5.tar.gz (10 kB)
Collecting google-auth-httplib2>=0.0.3
  Downloading google_auth_httplib2-0.0.4-py2.py3-none-any.whl (9.1 kB)
Collecting uritemplate<4dev,>=3.0.0
  Downloading uritemplate-3.0.1-py2.py3-none-any.whl (15 kB)
Collecting google-auth>=1.16.0
  Downloading google_auth-1.27.0-py2.py3-none-any.whl (135 kB)
     |████████████████████████████████| 135 kB 3.9 kB/s
Collecting httplib2<1dev,>=0.15.0
  Downloading httplib2-0.19.0-py3-none-any.whl (95 kB)
     |██████████                      | 30 kB 2.5 kB/s eta 0:00:26ERROR: Exception:
Traceback (most recent call last):
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
    yield
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\http\client.py", line 458, in read
    n = self.readinto(b)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\http\client.py", line 502, in readinto
    n = self.fp.readinto(b)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
    status = self.run(options, args)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\commands\install.py", line 323, in run
    requirement_set = resolver.resolve(
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 467, in prepare_linked_requirement
    local_file = unpack_url(
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 255, in unpack_url
    file = get_http_url(
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 129, in get_http_url
    from_path, content_type = _download_http_url(
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 282, in _download_http_url
    for chunk in download.chunks:
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\progress_bars.py", line 168, in iter
    for x in it:
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\network\utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\dell\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\users\dell\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.

E:\>
E:\>
E:\>python.exe -m pip install --upgrade pip
Collecting pip
  Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
     |███▌                            | 163 kB 7.1 kB/s eta 0:03:13ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
    yield
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 458, in read
    n = self.readinto(b)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 502, in readinto
    n = self.fp.readinto(b)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
    status = self.run(options, args)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\commands\install.py", line 323, in run
    requirement_set = resolver.resolve(
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 467, in prepare_linked_requirement
    local_file = unpack_url(
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 255, in unpack_url
    file = get_http_url(
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 129, in get_http_url
    from_path, content_type = _download_http_url(
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 282, in _download_http_url
    for chunk in download.chunks:
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\progress_bars.py", line 168, in iter
    for x in it:
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\network\utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'C:\Users\DELL\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip' command.

E:\>c:\users\dell\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip
Collecting pip
  Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 726 kB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.2.3
    Uninstalling pip-20.2.3:
      Successfully uninstalled pip-20.2.3
Successfully installed pip-21.0.1

E:\>
E:\>
E:\>
E:\>pip install autosub
Collecting autosub
  Using cached autosub-0.3.12.tar.gz (7.3 kB)
Collecting google-api-python-client>=1.4.2
  Using cached google_api_python_client-1.12.8-py2.py3-none-any.whl (61 kB)
Collecting requests>=2.3.0
  Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting pysrt>=1.0.1
  Using cached pysrt-1.1.2.tar.gz (104 kB)
Collecting progressbar>=2.3
  Using cached progressbar-2.5.tar.gz (10 kB)
Collecting google-api-core<2dev,>=1.21.0
  Downloading google_api_core-1.26.0-py2.py3-none-any.whl (92 kB)
     |████████████████████████████████| 92 kB 242 kB/s
Collecting six<2dev,>=1.13.0
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting google-auth-httplib2>=0.0.3
  Using cached google_auth_httplib2-0.0.4-py2.py3-none-any.whl (9.1 kB)
Collecting uritemplate<4dev,>=3.0.0
  Using cached uritemplate-3.0.1-py2.py3-none-any.whl (15 kB)
Collecting google-auth>=1.16.0
  Using cached google_auth-1.27.0-py2.py3-none-any.whl (135 kB)
Collecting httplib2<1dev,>=0.15.0
  Downloading httplib2-0.19.0-py3-none-any.whl (95 kB)
     |████████████████████████████████| 95 kB 252 kB/s
Collecting protobuf>=3.12.0
  Downloading protobuf-3.15.0-py2.py3-none-any.whl (173 kB)
     |████████████████████████████████| 173 kB 285 kB/s
Requirement already satisfied: setuptools>=40.3.0 in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (from google-api-core<2dev,>=1.21.0->google-api-python-client>=1.4.2->autosub) (49.2.1)
Collecting pytz
  Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 312 kB/s
Collecting packaging>=14.3
  Downloading packaging-20.9-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 439 kB/s
Collecting googleapis-common-protos<2.0dev,>=1.6.0
  Downloading googleapis_common_protos-1.52.0-py2.py3-none-any.whl (100 kB)
     |████████████████████████████████| 100 kB 402 kB/s
Collecting rsa<5,>=3.1.4
  Downloading rsa-4.7.1-py3-none-any.whl (36 kB)
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.2.1-py3-none-any.whl (12 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 328 kB/s
Collecting pyparsing<3,>=2.4.2
  Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
     |████████████████████████████████| 67 kB 459 kB/s
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 438 kB/s
Collecting chardet
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 327 kB/s
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 491 kB/s
Collecting certifi>=2017.4.17
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 437 kB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
     |████████████████████████████████| 137 kB 437 kB/s
Using legacy 'setup.py install' for autosub, since package 'wheel' is not installed.
Using legacy 'setup.py install' for progressbar, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pysrt, since package 'wheel' is not installed.
Installing collected packages: six, pyasn1, urllib3, rsa, pyparsing, pyasn1-modules, protobuf, idna, chardet, certifi, cachetools, requests, pytz, packaging, httplib2, googleapis-common-protos, google-auth, uritemplate, google-auth-httplib2, google-api-core, pysrt, progressbar, google-api-python-client, autosub
    Running setup.py install for pysrt ... done
    Running setup.py install for progressbar ... done
    Running setup.py install for autosub ... done
Successfully installed autosub-0.3.12 cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 google-api-core-1.26.0 google-api-python-client-1.12.8 google-auth-1.27.0 google-auth-httplib2-0.0.4 googleapis-common-protos-1.52.0 httplib2-0.19.0 idna-2.10 packaging-20.9 progressbar-2.5 protobuf-3.15.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyparsing-2.4.7 pysrt-1.1.2 pytz-2021.1 requests-2.25.1 rsa-4.7.1 six-1.15.0 uritemplate-3.0.1 urllib3-1.26.3

E:\>


下载并修改autosub
autosub是用于自动生成字幕的工具,在语音转写部分调用的是Google Cloud Speech API。

(1)安装autosub
pip install autosub
就可以完成autosub的安装。

(2)重命名autosub
autosub安装完成后文件位于“C:\Users\DELL\AppData\Local\Programs\Python\Python39\Scripts”内,将其重命名为“autosub_app.py”。

(3)修改autosub_app.py代码(原始的py文件针对linux系统的。)
这里对几处重点的修改展开说明,autosub_app.py的全部代码会在文末给出。
(直接替换即可。有兴趣的可以比对一下!)

由于这里下载安装的是linux版本的python2版本的autosub,所以要参考这里修改:
https://github.com/lkjell/autosub/tree/python3
lkjell/autosub
forked from agermanidis/autosub

autosub_app修改为:autosub_app.py,然后参照python2版本的autosub_app.py中加入代理即可!
C:\Users\DELL\AppData\Local\Programs\Python\Python39\Scripts\autosub_app

20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)

 

20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)

 

20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)

 

20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)


C:\Users\DELL\AppData\Local\Programs\Python\Python39\Lib\site-packages\autosub\formatters.py

20210219在WIN10下自动将视频文件生成字幕的软件autosub安装及使用(python3)

 


4、由于autosub必须访问google服务器,请确保你的电脑能够上Google/Facebook/Youtube等等外网!^_
开启w***.exe,在任务管理器→详细信息的最后面可以找到w***.exe即可。

360极速浏览器→工具→管理扩展→获取更多扩展程序→(搜索:SwitchyOmega)→Proxy SwitchyOmega
Proxy→代理协议(SOCKS5)→代理服务器(127.0.0.1)→代理端口(1080)→应用选项。

(可选,有点问题!)
auto switch→条件类型(网址正则)→条件设置(internal.example.com)不变→情景模式(proxy)
(选中)规则列表规则→(按照规则列表匹配请求)(不变)→直接连接
规则列表设置→规则列表格式→AutoProxy
规则列表网址:https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
立即更新情景模式。


图中的规则列表网址:
https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt


5、SOCKS5代理转HTTP代理:privoxy_setup_3.0.28.exe
D:\Program Files (x86)\Privoxy\config.txt
#      To chain Privoxy and Tor, both running on the same system, you
#      would use something like:
#
#        forward-socks5t   /               127.0.0.1:9050 .
(增加:)
forward-socks5t   /               127.0.0.1:9050 .
forward-socks5   /               127.0.0.1:1080 .


参考资料:
https://binglinggroup.github.io/archives/autosub%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97(windows%E5%8F%8Aubuntu).html#不能稳定连接google服务器的网络问题
autosub安装使用指南(windows及ubuntu)(200302)

不能稳定连接google服务器的网络问题
首先最大的问题是网络问题,如果你使用的是无法连接到google服务器的网络,windows端你可能需要在命令行界面下输入以下两个指令,以改变当前命令行的http proxy。注意http proxy一般由本地软件提供,譬如克莱士,127.0.0.1指本地IP,冒号后面的是本地软件提供的http proxy端口。

set http_proxy=http://127.0.0.1:1080
set https_proxy=https://127.0.0.1:1080
ubuntu也需要类似的指令给终端上代理,只是你需要注意本地proxy软件是否提供http proxy功能,如果只提供socks5 proxy,你需要使用polipo将其转为http proxy然后使用。

然而你依然可能遇到如图所示的错误(Connection broken),多是因为你的网络不够稳定导致的,原因大概是google speech api对网络比较挑剔。


Clone or download
遇到这种错误,你可能需要更换网络环境。通常来讲,将运行平台更换为可稳定连接至google服务器的云服务器会比更换proxy更加有效,具体方式参考[2]为什么此处推荐使用ubuntu?


百度搜索:socks5 proxy,将其转为http proxy然后使用.
https://blog.csdn.net/yyws2039725/article/details/90615740
Windows下使用Privoxy将socks5转为HTTP代理
马克88 2019-05-28 00:29:51  5798  收藏 2


下载:
https://sourceforge.net/projects/ijbswa/files/
https://sourceforge.net/projects/ijbswa/files/Win32/
https://sourceforge.net/projects/ijbswa/files/Win32/3.0.28%20%28stable%29/
下载:privoxy_setup_3.0.28.exe

不要默认安装到C盘,不然可能会出现错误:
Privoxy Error
Fatal error: init_error_log(): can't open logfile:'.\privoxy.log'

打开Privoxy安装目录下的主配置文件D:\Program Files (x86)\Privoxy\config.txt
代理的IP地址与监听端口listen-address(不用修改)
listen-address  127.0.0.1:8118

或者用本机局域网IP:
listen-address  192.168.1.11:8118

转发请求的代理IP地址与监听端口,例如tor的代理端口:
forward-socks5 / 127.0.0.1:9150 .

***一般监听端口为1080,
forward-socks5 / 127.0.0.1:1080 .

这里使用:(这里增加!)
#      To chain Privoxy and Tor, both running on the same system, you
#      would use something like:
#
#        forward-socks5t   /               127.0.0.1:9050 .

forward-socks5t   /               127.0.0.1:9050 .
forward-socks5   /               127.0.0.1:1080 .


然后手机或者虚拟机或者其他,设置代理IP:192.168.1.11,端口:8118
127.0.0.1:8008


6、字幕提取命令
这里需要再次打开工具Anaconda Powershell Prompt (Anaconda2),将工作目录切换至包含待提取字幕视频的目录内,例如D盘根目录下有一个待提取字幕的视频“01_HowComputersWork_sm.mp4”,首先将工作目录切换至D盘,然后执行命令:

python D:\Anaconda2\Scripts\autosub_app.py -S en -D en -P http://127.0.0.1:1080 .\01_HowComputersWork_sm.mp4
python autosub_app.py -S en -D en -P http://127.0.0.1:1080 d:\01_HowComputersWork_sm.mp4
python C:\Python27\Scripts\autosub_app.py -S zh-CN -D zh-CN -P http://127.0.0.1:8118 "走向共和01.avi"
python C:\Python27\Scripts\autosub_app.py -S zh-CN -D zh-CN -P http://127.0.0.1:8118 "走向共和02.avi"


D:\20201107在WIN10下自动将视频文件生成字幕的软件autosub安装及使用>python C:\Users\DELL\AppData\Local\Programs\Python\Python39\Scripts\autosub_app.py -S zh-CN -D zh-CN -P http://127.0.0.1:8118 "标准录音5不能吃.mp3"
Use proxy http://127.0.0.1:8118
[mp3float @ 0000017887befc80] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
Converting speech regions to FLAC files: 100% |#################| Time: 0:00:03
Performing speech recognition: 100% |###########################| Time: 0:00:23
Subtitles file created at 标准录音5不能吃.srt

D:\20201107在WIN10下自动将视频文件生成字幕的软件autosub安装及使用>
D:\20201107在WIN10下自动将视频文件生成字幕的软件autosub安装及使用>
D:\20201107在WIN10下自动将视频文件生成字幕的软件autosub安装及使用>
D:\20201107在WIN10下自动将视频文件生成字幕的软件autosub安装及使用>python e:\autosub_app.py -S zh-CN -D zh-CN -P http://127.0.0.1:8118 "标准录音5不能吃.mp3"
Use proxy http://127.0.0.1:8118
[mp3float @ 00000142b77ffc80] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
Converting speech regions to FLAC files: 100% |#################| Time: 0:00:02
Performing speech recognition: 100% |###########################| Time: 0:01:00
Subtitles file created at 标准录音5不能吃.srt

D:\20201107在WIN10下自动将视频文件生成字幕的软件autosub安装及使用>


这里假设你视频中的语言是国语,当然也可以是其他国别,这里是支持语言代码:
af Afrikaans
ar Arabic
az Azerbaijani
be Belarusian
bg Bulgarian
bn Bengali
bs Bosnian
ca Catalan
ceb Cebuano
cs Czech
cy Welsh
da Danish
de German
el Greek
en English
eo Esperanto
es Spanish
et Estonian
eu Basque
fa Persian
fi Finnish
fr French
ga Irish
gl Galician
gu Gujarati
ha Hausa
hi Hindi
hmn Hmong
hr Croatian
ht Haitian Creole
hu Hungarian
hy Armenian
id Indonesian
ig Igbo
is Icelandic
it Italian
iw Hebrew
ja Japanese
jw Javanese
ka Georgian
kk Kazakh
km Khmer
kn Kannada
ko Korean
la Latin
lo Lao
lt Lithuanian
lv Latvian
mg Malagasy
mi Maori
mk Macedonian
ml Malayalam
mn ***n
mr Marathi
ms Malay
mt Maltese
my Myanmar (Burmese)
ne Nepali
nl Dutch
no Norwegian
ny Chichewa
pa Punjabi
pl Polish
pt Portuguese
ro Romanian
ru Russian
si Sinhala
sk Slovak
sl Slovenian
so Somali
sq Albanian
sr Serbian
st Sesotho
su Sudanese
sv Swedish
sw Swahili
ta Tamil
te Telugu
tg Tajik
th Thai
tl Filipino
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
yi Yiddish
yo Yoruba
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
zu Zulu


参考资料:
https://blog.csdn.net/zcxey2911/article/details/107774549
https://www.jianshu.com/p/476b587b290b
基于Python3(Autosub)以及Ffmpeg配合GoogleTranslation(谷歌翻译)为你的影片实现双语版字幕(逐字稿)
刘悦的技术博客


https://zhuanlan.zhihu.com/p/65509702
9.1如何使用autosub自动生成音频视频字幕
安德鲁
10 人赞同了该文章


https://blog.csdn.net/weixin_43471336/article/details/108597555
autosub自动制作视频字幕
Lily(Li) 2020-09-15 15:09:16  103  收藏
参考文章
https://zhuanlan.zhihu.com/p/59159735
https://binglinggroup.github.io/archives/autosub%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97(windows%E5%8F%8Aubuntu).html


https://zhuanlan.zhihu.com/p/65509702
9.1如何使用autosub自动生成音频视频字幕


https://blog.csdn.net/eugene6666/article/details/84662831
自动将视频文件生成字幕的软件autosub安装及使用(支持英文、日语和法语)
eugene6666 2018-11-30 17:21:36  23626  收藏 7
文章标签: 字幕 Python
@自动将视频文件生成字幕的软件autosub安装及使用(支持英文、日语和法语)
For more information and download links of the software that you may use, please see https://github.com/agermanidis/autosub/issues/31


https://blog.csdn.net/kingroc/article/details/92818557
Python音频转文字之autosub(Ubuntu)
王小鹏鹏 2019-06-19 12:08:46  9936  收藏 9


https://blog.csdn.net/m0_46603114/article/details/105221160
英文视频字幕自动生成
码农甲V 2020-03-31 14:23:18  2107  收藏 5  原力计划

上一篇:CentOS7.3学习笔记总结(七十二)


下一篇:Java面试突击1