Some time ago I mentioned the subed-mode, Emacs mode for editing srt
files with movie subtitles. Well, I’ve been using it regularly for more than half a year now, and I used it to translate more than 20 hours of material into Polish, spending more than 100 hours on it altogether. (And before you ask, this is – again – a hobby/amateur project for my family, not even published.) I think I can safely say that I know quite a bit more about subed-mode
now – for instance, I now know that it supports playing the video and actually syncing it to the subtitle at point (with some margins, of course), which is absolutely great.
It had some shortcomings, though. One was that while it supported starting and pausing the video, there was no support for stepping one frame forward or backward. This was a shame, since sometimes it is important to sync the subtitles as precisely as possible to what is happening on the screen. (I also learned in the meantime that srt
is not really what professionals use, but I don’t mind that – after all, what I’m doing is just a hobby project.) Another one was that I sometimes needed to use simple formatting (basically, render some part in italics), and typing HTML-like tags manually (which is what the srt format requires) is quite tedious.
However, the thing I missed the most was calculating CPS, or characters per second. It is a well-known fact that translating a text from English to Polish almost always makes it longer. (I remember reading somewhere, many years ago, that a Polish text is on average about 20% longer than its English equivalent. I have no idea where or when I read it – it might as well be before I had any access to the Web – and if that is even true. A quick Google search gave conflicting results. Some people claim that translating from any language to any other tends to make the text longer, which also sounds reasonable – and actually pretty fascinating.) It turns out that the industry standard is 17 CPS for subtitles, with 20 CPS being tolerated in special circumstances, and my subtitles were sometimes even in the 25–30 range! No wonder my dear wife couldn’t keep up – she reads like a normal person, which means much slower than me. (And before you start to be envious – reading fast is a curse as well as a blessing, so to speak, since if I want to read something for pleasure, I sometimes have to put concious effort into reading slower… Also, as a complete side-note, let me also mention that spending more than a decade as a proofreader apparently did some things to my brain. Sometimes I look at a text and perceive a slight discomfort, meaning there’s a typo. Then I have to read it word by word, very slowly and carefully, maybe even twice, to actually find the typo my subconscious noticed in a fraction of a second. This phenomenon both fascinates and terrifies me.)
A careful reader must have noticed that I wrote about the issues with subed-mode
in past tense. Well, I did what every programmer would do – I implemented some changes. Most notably, I wrote a CPS-calculating function for subed-mode (which was – expectedly – very easy), and then spent some time writing code to display and update it dynamically while working on the text. That turned out to be a little more difficult than I thought, but I am now happy to say that it works pretty reliably.
Coming back – I submitted a couple of PRs with my changes (CPS display, inserting HTML-like tags and moving by one frame), and after a short back-and-forth (revealing some easy-to-solve bugs or poor keybinding choices) they got accepted and are now included in the master branch if you need these features. Of course, the CPS calculation is the most visible (and cool) one.
If you look carefully and count, you’ll notice that the HTML-ish tags are excluded from the calculation. This feature is not very robust, i.e., it assumes they are correctly formed and don’t contain the “greater-then” sign in their “attribute” part (IOW, it just disregards everything from a <
to the next occurrence of a >
). Of course, you can turn this behavior off (or supply a better function to strip the tags – see the source for the details).
I have to say that rndusr, the author and maintainer of subed-mode, was very responsive and helpful, and his suggestions concerning the UI made these features much better. Thanks!
Having this, I figured there are more potentially useful things you could so with subed-mode
. Probably the coolest one would be to be able to see not only the video, but also a visual rendering of the underlying soundwave, and fit the subtitles to the precise moments people start talking etc. This, however, would be much more work, and not really that much needed for a hobby project like mine, so I decided to postpone this idea until I have much more time. And in fact an even more useful feature would probably be to add support for more formats, like EBU STL, which is apparently the industry standard used by professionals. Yet another great thing would be to have a subtitle linter, detecting common errors, and linking it to flymake
(this sounds like something I might be actually tempted to code one day!).
Anyway, if you ever need to edit srt
(or vtt
) subtitles with Emacs, I am quite proud to say that the experience is now even better!