Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Nikogori on June 05, 2018, 03:21:50 pm

Title: Adding subtitles to FS2 cutscenes
Post by: Nikogori on June 05, 2018, 03:21:50 pm
Related threads:

Questions about the Translation features (https://www.hard-light.net/forums/index.php?topic=94498.0)
Unicode text support (https://www.hard-light.net/forums/index.php?topic=94159.40)

I'm modifying old Japanese localization mod (http://stardogs.netgamers.jp/index.php?FreeSpace%20Series%2FFreeSpace%202%2F%C6%FC%CB%DC%B8%EC%B2%BD%A5%D7%A5%ED%A5%B8%A5%A7%A5%AF%A5%C8) so that it can be used with FSO.

Most errors have been ironed out, and now I'm thinking about adding subtitles to cutscene movies.
(This was never a problem for old Japanese mod, because it can not play movie files.)

I believe I understand how SRT subtitles work (at least it is working on MPC-HC).
I'd like to know where I should place these SRT files.

I'm using latest Nightly and it always gives me the same error when I enter the cutscene sequence (such as bastion.mve).
(https://i.imgur.com/H2yGdvx.png)

I have added $Movie subtitle font: to mod.tbm and a truetype font but it gave me almost the same error.
(https://i.imgur.com/PBAlcPM.png)
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 05, 2018, 03:48:17 pm
The font name must be a name of a font entry specified in fonts.tbl and not a simple TTF file name.

FSO currently only supports subtitles that are embedded in the movie file. In my tests I did that with FFmpeg. Generally, the subtitle code of FSO is not very well tested since I did not have much data to test it with when I wrote that code originally.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Novachen on June 05, 2018, 03:58:11 pm
I actually recommend to create own movie files with an embedded graphic subtitle instead.

Simply because it allows you to design the subtitle exactly like you wish it should appear, you can control the position and their size and you can add subtitle effects to it, if you wish.

And because we are talking about the FS2 cutscenes in 480p here, they will not have a big download size if you reencode them into MP4 with CRF10 or 12 or something like that.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Nikogori on June 06, 2018, 02:06:06 pm
The font name must be a name of a font entry specified in fonts.tbl and not a simple TTF file name.

Thank you. I have added +Name: font01 to fonts.tbl and $Movie subtitle font: font01 to mod.tbm and the error message has disappeared.

I actually recommend to create own movie files with an embedded graphic subtitle instead.

Simply because it allows you to design the subtitle exactly like you wish it should appear, you can control the position and their size and you can add subtitle effects to it, if you wish.

And because we are talking about the FS2 cutscenes in 480p here, they will not have a big download size if you reencode them into MP4 with CRF10 or 12 or something like that.

Actually this is much easier for me because a few years ago I made videos like this:

However, you need to create movie files at higher resolution than 480p. Because video cutscenes will be stretched out in the game and subtitles will get blurry.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 06, 2018, 02:11:39 pm
If you give me a movie file which uses subtitles with some more advanced features I can take a look at how those features could be implemented. Alternatively, if you have a standalone SRT file I could try adding code for reading that with FFmpeg.

The bottom line is this: If you give me more subtitle data I may be able to implement the missing features :p
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Nikogori on June 06, 2018, 02:37:05 pm
If you give me a movie file which uses subtitles with some more advanced features I can take a look at how those features could be implemented. Alternatively, if you have a standalone SRT file I could try adding code for reading that with FFmpeg.

The bottom line is this: If you give me more subtitle data I may be able to implement the missing features :p

Do you need sample SRT files? I made a SRT file for Diaspora mission 2 briefing when I downloaded Subtitle Edit (http://www.nikse.dk/subtitleedit).

It is supposed to look like this:
(https://i.imgur.com/n69C0k7.png)

[attachment stolen by Russian hackers]
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 06, 2018, 02:43:10 pm
Thank you, I'll check if ffmpeg can read SRT without a movie file.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 06, 2018, 09:08:44 pm
I wrote some code that appears to be working, here are some test builds: http://swc.fs2downloads.com/builds/test/externalSubtitles/

The way this works is that you place your .srt file in the same directory as the movie file and name it <movie name>-<extension>.srt where "<extension>" is the value of +Extension: given for that language in strings.tbl. I did not have the unicode mode set up for Diaspora so I could not see the proper text but it appeared to be changing in the right intervals so I guess that it is working.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Nikogori on June 07, 2018, 02:21:06 pm
I wrote some code that appears to be working, here are some test builds: http://swc.fs2downloads.com/builds/test/externalSubtitles/

It's working! Thank you!
(https://i.imgur.com/Bl7mhLq.png)

There's still one more thing I'd like to ask you. Can you add text shadows to subtitles?
Sometimes "white text on white background" is hard to read.

I did not have the unicode mode set up for Diaspora so I could not see the proper text but it appeared to be changing in the right intervals so I guess that it is working.

Sorry for inconvenience. I have attached Japanese subtitle files for FS2 intro and Bosch monologue 1.

[attachment stolen by Russian hackers]
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 07, 2018, 02:28:05 pm
It's working! Thank you!
Great! Thank you for testing.

There's still one more thing I'd like to ask you. Can you add text shadows to subtitles?
Sometimes "white text on white background" is hard to read.
Unfortunately, that effect is actually surprisingly hard to implement so for the moment that effect is nor supported by FSO, sorry...
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Nikogori on June 07, 2018, 02:50:11 pm
There's still one more thing I'd like to ask you. Can you add text shadows to subtitles?
Sometimes "white text on white background" is hard to read.
Unfortunately, that effect is actually surprisingly hard to implement so for the moment that effect is nor supported by FSO, sorry...

Don't worry. Since FreeSpace2 is a space sim there won't be too many white background. :lol:
Fortunately the game allows me to change font size via fonts.tbl quite easily. I guess bigger fonts will make it easier to read in most cases.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 07, 2018, 02:51:46 pm
I am working on some improvements to the font rendering which may allow adding outlines to fonts with a different color than the inside of the font but it will take a while until those changes are stable.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Bryan See on June 08, 2018, 07:44:05 pm
Cool! When we can at least see it committed to main code?
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 08, 2018, 09:55:17 pm
See what committed? I already opened a PR for the subtitle code which should be merged soon.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: karajorma on June 09, 2018, 10:24:40 am
I actually recommend to create own movie files with an embedded graphic subtitle instead.

I'd recommend against that. Using subtitle files makes it very easy to switch languages and since they are tiny they can all go in a VP file and be forgotten about. I dislike the idea of having separate mods based on language. It just causes confusion and bloat. Not to mention serious problems if a mod ever decides to change one of their cutscenes.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Novachen on June 09, 2018, 10:43:57 am
If there were support for a graphic layer, then i would agree, yes. But in many cases text subtitles simply limits your possibilites too much. For example, you can only translate the voice over, but not texts, that appears at the same time.

It has a reason why i have decided myself for own cutscenes and against the use of SRTs. So it was my recommendation based on my experiences i have collected and based on my demands i have for atleast my own translation packages. And because you will likely have to download specific languages as an own mod anyway (because it could be hard to implement spelling updates etc. otherwise), you have seperate downloads anyway.

If the SRT support is enough for Nikogori and his translation attempt, fine. It is his project after all, with his own ideas and visions. Every one has different demands on how a translation should appear. For me SRT simply are too restictive. That's everything :)
Title: Re: Adding subtitles to FS2 cutscenes
Post by: The E on June 09, 2018, 10:57:34 am
If you have the ressources to rerender your cutscenes every time someone makes a translation, that's cool and more power to you.
But I would assume that, for the majority of people, providing subtitle files is the easiest and fastest way to do what they want or need to do.

Also, providing a new localization as a bunch of text files is still easier and less bandwidth-intensive than cutscenes.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Nikogori on June 09, 2018, 04:28:02 pm
I prefer SRT subtitles because they are far easier to make small update. I remember the moment when I uploaded a video with embedded subtitles that took me a couple of months to make and suddenly noticed a typo as I was watching it...
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Bryan See on June 09, 2018, 05:06:42 pm
SRT subtitles is a must.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 09, 2018, 08:37:50 pm
SRT support has been merged into master already and should appear in the next nightly build. I am working on implementing ASS support but that will take some additional time since the format is more complicated than SRT.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Bryan See on June 10, 2018, 04:25:11 am
ASS support? What is that? Not to be confused with the word "a**"...
Title: Re: Adding subtitles to FS2 cutscenes
Post by: karajorma on June 10, 2018, 07:23:05 am
It's a subtitle format with a rather unfortunate name. Like srt but with more features.
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Mongoose on June 10, 2018, 02:31:22 pm
It's basically what every fansubbing group out there uses, which means it's capable of a vast array of obnoxious over-the-top effects. :p
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Axem on June 10, 2018, 03:59:39 pm
it's capable of a vast array of obnoxious over-the-top effects. :p

(https://cdn.discordapp.com/emojis/334462614421897217.png?v=1)
Title: Re: Adding subtitles to FS2 cutscenes
Post by: m!m on June 10, 2018, 04:00:36 pm
Sorry Axem, I'm not going to implement a complete ASS subtitle renderer :p
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Axem on June 10, 2018, 04:39:12 pm
 :(
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Nightmare on June 10, 2018, 05:50:58 pm
A stripped version, so to say. :p
Title: Re: Adding subtitles to FS2 cutscenes
Post by: Bryan See on June 11, 2018, 04:13:07 am
Then improve it.