我要做的全部事情就是下载一些课程,这些课程在 youtube 上对我有很大帮助,并在视频中嵌入 Zh-Hans 字幕,然后将其提交到不支持外部字幕的中文网站。
这个东西可以帮助那些英语说得不好并且无法访问 youtube 的中国学生。
Youtube-dl config
文件路径是 ~/.config/youtube-dl/config
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 
 | --o '%(playlist_index)02ds - %(title)s.%(ext)s'--no-mtime
 --proxy socks5://127.0.0.1:1080
 
 --ignore-errors
 
 -f bestvideo[height<=?1080]+bestaudio/best
 
 --merge-output-format 'mkv'
 
 --write-auto-sub --sub-lang 'zh-Hans'
 
 --convert-subs 'ass'
 
 --embed-subs
 
 | 
同时下载
| 12
 3
 4
 5
 6
 7
 8
 9
 
 | playlist='https://www.youtube.com/playlist?list=...'num=70
 i=1
 while (($i <= $num))
 do
 end=$(( i+1 ))
 youtube-dl --playlist-start $i --playlist-end $end $playlist > "log-$i-$end.txt"  2>&1  &
 i=$(($end+1))
 done
 
 | 
批量翻译文件名
下载列表中的所有视频后,用
ls | grep mkv | sed "s/\.mkv//"
然后复制并粘贴到 Google 以获取翻译后的文本,然后将其保存到 zh.txt
批量嵌入字幕
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 
 | tmp="tmp.mkv"mkdir -p embedSub
 for f in *.mkv; do
 read -r zh <&3
 echo "$f\n$zh"
 
 cp $f $tmp
 ffmpeg -nostats -loglevel 24 -n -i $tmp -vf subtitles=$tmp "embedSub/$zh.mkv";
 done 3<zh.txt
 
 rm $tmp
 
 | 
在 Intel Core i7 上,我通常花了一整夜的时间来录制 20 个视频,而一个小时的视频需要 20 分钟才能嵌入其字幕。