Loading... <strong>说明:</strong>很多时候我们下载视频的时候,都是么得字幕的,对于强迫症或者有其他需求的人来说,都需要加进去,一般都是首先去其它字幕网站下载后,使用<code>ffmpeg</code>或者一些转码程序将字幕烧录进去,通常来说,手动获取字幕还是比较麻烦的,这里就分享一个工具<code>GetSub</code>,可以自动给我们根据某个视频或者视频文件夹,匹配出相应的<code>ass</code>/<code>srt</code>字幕文件,字幕来源于<a href="http://subhd.com/" target="_blank" rel="noopener noreferrer">subhd</a>、<a href="http://www.zimuzu.tv/" target="_blank" rel="noopener noreferrer">zimuzu</a>和<a href="https://www.zimuku.la/" target="_blank" rel="noopener noreferrer">zimuku</a>,获取速度也是很快的,有需求的可以用下。 <div data-unique="截图"></div> <h2>截图</h2> <a class="light-link" href="http://www.502435.com/usr/uploads/2020/04/dd064-getsub.png" data-fancybox="gallery" data-type="image" data-caption="请输入图片描述"><img title="请输入图片描述" src="http://www.502435.com/usr/uploads/2020/04/dd064-getsub.png" alt="请输入图片描述" style=""></a> <div data-unique="安装"></div> <h2>安装</h2> <strong>Github地址:</strong><a href="https://github.com/gyh1621/GetSubtitles" target="_blank" rel="noopener noreferrer">https://github.com/gyh1621/GetSubtitles</a> <strong>环境要求:</strong><code>Python 2</code>或<code>3</code>,建议使用<code>Python 3</code>。 <strong>1、安装pip或pip3</strong> <pre><code class="hljs">提示:pip和pip3自己选一种进行安装。 </code></pre> 安装<code>pip</code>: <pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash">CentOS 6.x 32位</span> rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install -y python-pip <span class="hljs-meta"> #</span><span class="bash">CentOS 6.x 64位</span> rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install -y python-pip <span class="hljs-meta"> #</span><span class="bash">CentOS 7.x</span> yum install -y epel-release yum install -y python-pip <span class="hljs-meta">#</span><span class="bash">如果CentOS 7安装出现No package python-pip available,可以用以下命令进行安装</span> wget https://bootstrap.pypa.io/get-pip.py python get-pip.py <span class="hljs-meta"> #</span><span class="bash">Debian/Ubuntu系统</span> apt -y update apt -y install python-pip </code></pre> 安装<code>pip3</code>: <pre><code class="hljs cs"><span class="hljs-meta">#CenOS 6系统</span> rpm -Uvh https:<span class="hljs-comment">//dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm</span> yum install python34 -y wget https:<span class="hljs-comment">//bootstrap.pypa.io/get-pip.py</span> python3 <span class="hljs-keyword">get</span>-pip.py <span class="hljs-meta">#CenOS 7系统</span> rpm -Uvh https:<span class="hljs-comment">//dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm</span> yum install python36 -y wget https:<span class="hljs-comment">//bootstrap.pypa.io/get-pip.py</span> python3 <span class="hljs-keyword">get</span>-pip.py <span class="hljs-meta">#Debian/Ubuntu系统</span> apt update apt install python3-pip python3-setuptools python3-wheel -y </code></pre> <strong>2、安装GetSub</strong> <pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash">pip安装</span> pip install getsub <span class="hljs-meta"> #</span><span class="bash">pip3安装</span> pip3 install getsub </code></pre> <strong>3、使用方法</strong> <pre><code class="hljs nginx"><span class="hljs-comment">#使用命令</span> <span class="hljs-attribute">getsub</span> [-h] [-q] [-s] [-o] [-m] [-n NUMBER] [-b] [-d DOWNLOADER] [--<span class="hljs-literal">debug</span>] [--plex] name <span class="hljs-comment">#参数详解</span> -h 帮助 -q 查询模式,手动选择下载的压缩包,多选使用<span class="hljs-string">','</span>或<span class="hljs-string">','</span>分隔 -s 手动选择下载压缩包中要解压的字幕 -o 若视频存在同名字幕,替换已经存在的字幕 -m 保存原始下载字幕压缩包(通常一个字幕压缩包含有多个字幕) -b 若一个字母压缩包内同时有.ass、.srt类型字幕,保存两种字幕 -n 查询模式下显示最大候选字幕数 -d 选择下载器,subhd、zimuku、zimuzu --plex 在下载完成的字幕名中插入.zh标识供plex识别为中文字幕 --<span class="hljs-literal">debug</span> 显示报错详细信息 </code></pre> 下载指定视频的字幕,使用命令: <pre><code class="hljs css">#自动给你匹配它认为最合适的字幕,一般是<span class="hljs-selector-tag">ass</span>格式、双语字幕 <span class="hljs-selector-tag">getsub</span> <span class="hljs-selector-tag">Aladdin</span><span class="hljs-selector-class">.2019</span><span class="hljs-selector-class">.720p</span><span class="hljs-selector-class">.WEBRip</span><span class="hljs-selector-class">.x264</span> #自动查询字幕文件,并让你选择合适的下载 <span class="hljs-selector-tag">getsub</span> <span class="hljs-selector-tag">-q</span> <span class="hljs-selector-tag">-s</span> <span class="hljs-selector-tag">Aladdin</span><span class="hljs-selector-class">.2019</span><span class="hljs-selector-class">.720p</span><span class="hljs-selector-class">.WEBRip</span><span class="hljs-selector-class">.x264</span> </code></pre> 以上命令默认将字幕文件下载到当前执行目录,如果想下载到指定目录,比如<code>/moerats</code>,那后面就使用<code>/moerats/电影名称</code>。 批量下载视频文件夹所有视频的字幕,使用命令: <pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash">自动匹配/moerats文件夹里的所有视频最合适的字幕,并直接给你下载到/moerats目录</span> getsub /moerats <span class="hljs-meta"> #</span><span class="bash">批量查询/moerats文件夹里的所有视频的字幕文件,并让你选择合适的下载</span> getsub -q -s /moerats</code></pre> 最后就可以自行将字幕烧录进视频了。 使用<code>ffmpeg</code>烧录字幕的方法大致为: <pre><code class="hljs nginx"><span class="hljs-comment">#安装ffmpeg</span> <span class="hljs-attribute">wget</span> https://www.moerats.com/usr/down/ffmpeg/ffmpeg-git-$(getconf LONG_BIT)bit-static.tar.xz tar xvf ffmpeg-git-*-static.tar.xz mv ffmpeg-git-*/ffmpeg ffmpeg-git-*/ffprobe /usr/bin/ rm -rf ffmpeg-git-* <span class="hljs-comment">#简单的烧录命令</span> ffmpeg -i input.mp4 -vf subtitles=input.ass output.mp4 </code></pre> <code>input.mp4</code>为视频文件,<code>subtitles</code>后面为字幕文件,可以是<code>srt</code>/<code>ass</code>,<code>output.mp4</code>为输出文件,更多命令可以自行百度/谷歌。 最后修改:2022 年 08 月 02 日 © 允许规范转载 打赏 赞赏作者 赞 0 如果觉得我的文章对你有用,请随意赞赏