Skip to content

Instantly share code, notes, and snippets.

@afeicool
Forked from nickyfoto/video_sub_dl.sh
Created January 16, 2023 04:25
Show Gist options
  • Save afeicool/cf5fc16b450c169c3a9d8b85e184e077 to your computer and use it in GitHub Desktop.
Save afeicool/cf5fc16b450c169c3a9d8b85e184e077 to your computer and use it in GitHub Desktop.
Download video and its subtitle and merge subtitle to it.
# list available subtitles
# https://superuser.com/questions/927523/how-to-download-only-subtitles-of-videos-using-youtube-dl
youtube-dl --list-subs https://www.youtube.com/watch?v=lmWh9jV_1ac
# download a particular subtitle
youtube-dl --write-sub --sub-lang zh-CN --skip-download https://www.youtube.com/watch\?v\=lmWh9jV_1ac
# download auto generated sub
youtube-dl --write-auto-sub --sub-lang zh-CN --skip-download https://www.youtube.com/watch\?v\=lmWh9jV_1ac
# https://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles
# https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/subtitle_options
ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng outfile.mp4
# if your ffmpeg has libass enabled at compile time, you can directly do:
ffmpeg -i mymovie.mp4 -vf subtitles=subtitles.srt mysubtitledmovie.mp4
# https://askubuntu.com/questions/486297/how-to-select-video-quality-from-youtube-dl
# list all available video format
youtube-dl -F 'http://www.youtube.com/watch?v=P9pzm5b6FFY'
# download a particular one
youtube-dl -f 22 'http://www.youtube.com/watch?v=P9pzm5b6FFY'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment