Youtube Archival

Youtube is slowly (but surely) phasing out it’it’s support for custom subtitle in their videos, so it’s best to start archiving videos with notable subtitle work, either fan-created/supported or not. Or in general! You never know when one video will be delisted, or even the uploader banned, from youtube or not. I already have my own share of regrets in the past, and now trying not to make the same mistake. Always archive those that you think is worth saving.

You’ll need yt-dlp (link), ytsubconverter (link), and ffmpeg (you should have this already as one of yt-dlp’s dependencies), though honestly any kind of software that lets you insert softsubs to a video file will work. The first is to download video and subtitle from youtube, second is to convert said subtitle format so that it can be read by your media player, and the third as a way to insert the converted subtitle file into the downloaded video file.

First, the command for yt-dlp:

yt-dlp -f "bv*+ba" --write-subs --sub-langs en --sub-format srv3 --merge-output-format mkv {youtube-url} -o '%(uploader)s - %(title)s.%(ext)s'

This downloads video with yt-dlp with highest video and audio quality possible alongside .srv3 (youtube’s proprietary custom subtitle). I personally use .mkv for the container just because I prefer it, but .mp4 is also supported — it’s also the source format used by youtube for video stream; As a note, youtube uses .opus for audio stream, but the condition of having best video format without audio data is very unlikely and most of the time the .mp4 file should have the best audio stream as well.

Next will be to convert the downloaded .srv3 to more common subtitle file format:

ytsubconverter input.srv3 --visual output.ass

This reverse-converts previous .srv3 subtitle to .ass with ytsubconverter with the subtitle styling applied (using --visual flag). srt subtitle format doesn’t support subtitle styling, though ytsubconverter supports converting from .sbv, the subtitle format you get when downloading subtitle from youtube subtitle editor, to .srt so you can edit it with aegisub.

Then, to merge the subtitle file into video:

ffmpeg -i input.mkv -f ass -i input.ass -map 0:0 -map 1:0 -c:v copy -c:a copy -c:s ass output.mkv

This will create a video file with softcoded subtitle embedded (as opposed of hardcoded, embedded directly into the video stream) with matroska (.mkv) format, with blazing speed since we’re just copying input data stream rather than transcoding them into new data format.

This is good for archival & preservation sake, since we didn’t do any tampering to the original video (and audio) file, and adding subtitle that can be turned on and off in convenient manner for most video player, without the need of having both video and subtitle file in the same directory.