OldCoderSubject: <a class="hashtag" href="https://dansu.org/tag/ffmpeg" rel="nofollow noopener" target="_blank">#ffmpeg</a> <a class="hashtag" href="https://dansu.org/tag/video" rel="nofollow noopener" target="_blank">#video</a> <a class="hashtag" href="https://dansu.org/tag/subtitles" rel="nofollow noopener" target="_blank">#subtitles</a><br><br>I've been using "ffmpeg" to add subtitles to videos as follows:<br><br>Start with a video and a ".srt" subtitles file. Add a black panel at the bottom of the video. The panel is tall enough to hold two lines of text. Scale the video down, if necessary, to make this possible. The need depends on aspect ratio. Burn subtitles into the panel by way of the "ffmpeg" "subtitles" filter. Use a yellow font.<br><br>This approach produces nice results. Subtitles are more readable this way and they also don't mess up the video. However, there is one issue. There seems to be no way in this approach to make 1-line and 2-line subtitles start at the same vertical offset.<br><br>But one can do this using "ffmpeg" "ass" support instead of "srt" support. I got this working sbout an hour ago.<br><br>The process is to convert "srt" to "ass" and then to add two different styles to the "ass" code. One style is for 1-line subtitles and the other is for 2-line subtitles. The finishing touch is to patch each line of dialogue in the "ass" code to use the appropriate style.<br><br>I've written "bash" and "perl" code to handle all of that. The code will be released as FOSS down the road as part of a video toolkit that I'm working on.<br><br>It works, as shown in the screenshots. The top lines of the subtitles line up exactly. But I'd be curious as to whether or not there's a simpler way to do this. If not, it's surprising.<br><br>Illustration: Screenshots from "Wizards", a 1977 S.F. and fantasy film written, directed and produced by Ralph Bakshi. The film is unusual in that it includes both elves and traditional post-apocalyptic human mutants.