Subtitling frustrations... and fun.
Sunday, 17 February 2019 18:06![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
So, I did my first professional task that involved a tiny bit of coding.
The task was to do subtitle styling for a movie, and to teach some other people how to do that task by themselves later. Only, I had to work out myself how the styling actually worked before I could do anything else. What they wanted was hard-coded subtitles that look like subtitles do on TV - as in, with two clearly separated lines of text on a semi-transparent background. Oh, and they had to be aligned to the centre, but with a straight left margin as well.
So, the big challenge here was to get the two separate lines of text, because there is no setting that indicates vertical space in the subtitle format I was supposed to use. I could easily put either a box around the subtitles, or draw a background across the whole width of the screen, but neither of those options were what I was after. I have to admit, it took me a lot of fiddling around to work out how to do this - even so much that I kind of gave up at one point... only I started working on it again the next day anyway.
The solution was to add a rotation code to every subtitle string that had two lines in it. If you move the rotation point very far off the screen, the end result is that the two lines get pushed apart without getting rotated at all. I don't understand maths or geometry, so I can't explain why that works, but it did. Only... it's not so fun to add the rotation code manually if you have hundreds, or even thousands, of lines of text, so I figured I needed a script for that. Now, my minimal coding skills are not nearly good enough to do that myself, so I was happy when I found someone who had uploaded a script that did kind of what I was after. His script pushed the text like 7cm apart, though, so I simply had to adjust some numbers to get a spacing that was more like what I was after. That, of course, involved figuring out where in the code to adjust that. So, nothing big, but it kind of looked impressive when I could send a mail and say "Look, I have a few scripts for you. This is how you can do subtitle spacing."
Once I had the spacing right, the rest of the task was just about finding the right settings for the background and the transparency levels. Finally, the center alignment with a straight left margin proved to be impossible in the preferred subtitling format - it even says in the documentation that "this is a format limitation", so I guess it's really not possible to do with a simple setting. What IS possible to do, however, is pushing the left margin further towards the middle, and that works well enough. It's not exactly the same as centered text, but the effect is similar enough.
So, task done, and I'm kind of pleased with myself for that.
The task was to do subtitle styling for a movie, and to teach some other people how to do that task by themselves later. Only, I had to work out myself how the styling actually worked before I could do anything else. What they wanted was hard-coded subtitles that look like subtitles do on TV - as in, with two clearly separated lines of text on a semi-transparent background. Oh, and they had to be aligned to the centre, but with a straight left margin as well.
So, the big challenge here was to get the two separate lines of text, because there is no setting that indicates vertical space in the subtitle format I was supposed to use. I could easily put either a box around the subtitles, or draw a background across the whole width of the screen, but neither of those options were what I was after. I have to admit, it took me a lot of fiddling around to work out how to do this - even so much that I kind of gave up at one point... only I started working on it again the next day anyway.
The solution was to add a rotation code to every subtitle string that had two lines in it. If you move the rotation point very far off the screen, the end result is that the two lines get pushed apart without getting rotated at all. I don't understand maths or geometry, so I can't explain why that works, but it did. Only... it's not so fun to add the rotation code manually if you have hundreds, or even thousands, of lines of text, so I figured I needed a script for that. Now, my minimal coding skills are not nearly good enough to do that myself, so I was happy when I found someone who had uploaded a script that did kind of what I was after. His script pushed the text like 7cm apart, though, so I simply had to adjust some numbers to get a spacing that was more like what I was after. That, of course, involved figuring out where in the code to adjust that. So, nothing big, but it kind of looked impressive when I could send a mail and say "Look, I have a few scripts for you. This is how you can do subtitle spacing."
Once I had the spacing right, the rest of the task was just about finding the right settings for the background and the transparency levels. Finally, the center alignment with a straight left margin proved to be impossible in the preferred subtitling format - it even says in the documentation that "this is a format limitation", so I guess it's really not possible to do with a simple setting. What IS possible to do, however, is pushing the left margin further towards the middle, and that works well enough. It's not exactly the same as centered text, but the effect is similar enough.
So, task done, and I'm kind of pleased with myself for that.