Video API

For porting of the campaign to javascript discussions
Post Reply
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3776
Joined: 03 Aug 2006, 19:39

Video API

Post by Per » 26 Aug 2017, 15:32

I'm trying to redo the horrible video interface, giving greater control to the scripting language, and bypassing the whole 'message' system. But there are a few things I'm unsure of.

First, where should we store subtitles? My first idea was to put them in the scripting language itself, like this:

Code: Select all

                var subtitles = [
                               	{ "x": 0.42, "y": 0.83, "text": "CAMPAIGN ONE", "start": 0.0, "end": 4.0, "justify": false },
                                { "x": 0.40, "y": 0.87, "text": "WESTERN SECTOR", "start": 0.0, "end": 4.0, "justify": false },
                               	{ "x": 0.03, "y": 0.03, "text": "Dawn, July 4th, 2100", "start": 4.04, "end": 15.98, "justify": false },
                                { "x": 0.00, "y": 0.00, "text": "Project HQ", "start": 4.04, "end": 15.96, "justify": false },
                               	{ "x": 0.00, "y": 0.00, "text": "A New Era", "start": 4.04, "end": 15.96, "justify": false },
                                { "x": 0.03, "y": 0.03, "text": "Morning, July 4th, 2100", "start": 19.96, "end": 31.96, "justify": false },
                                { "x": 0.00, "y": 0.00, "text": "In-flight to Western Sector", "start": 19.96, "end": 31.96, "justify": false },
                               	{ "x": 0.00, "y": 0.00, "text": "Team Alpha nears its destination", "start": 19.96, "end": 31.96, "justify": false },
                               	{ "x": 0.03, "y": 0.03, "text": "OBJECTIVE: Locate and recover neural synapse technology", "start": 50.0, "end": 69.0, "justify": false },
                               	{ "x": 0.03, "y": 0.93, "text": "Establish a base, then search for a Pre-Collapse structure.", "start": 50.0, "end": 69.0, "justify": false },
                               	{ "x": 0.00, "y": 0.00, "text": "This structure contains technology vital for the success of the Project.", "start": 50.0, "end": 69.0, "justify": false },
                               	{ "x": 0.03, "y": 0.90, "text": "Transport destinations follow:", "start": 4.0, "end": 8.0, "justify": false },
                               	{ "x": 0.00, "y": 0.00, "text": "Alpha - Western Sector....", "start": 4.0, "end": 8.0, "justify": false },
                                { "x": 0.03, "y": 0.90, "text": "Alpha you are cleared for take-off.", "start": 9.0, "end": 14.0, "justify": false },
                                { "x": 0.00, "y": 0.00, "text": "Good luck and good hunting.", "start": 9.0, "end": 14.0, "justify": false },
                               	{ "x": 0.03, "y": 0.90, "text": "Approaching Landing Zone. Team Alpha Briefing commences.", "start": 30.0, "end": 35.0, "justify": false },
                                { "x": 0.03, "y": 0.90, "text": "Commander, you lead Team Alpha, one of three expeditionary teams sent out by the Project to recover artifacts from before the Collapse.", "star$
                                { "x": 0.03, "y": 0.90, "text": "Your destination lies in the western zone.", "start": 47.0, "end": 49.6, "justify": false },
                var videos = [ { "video": "cam1/c001.ogg", "loop": false, "subtitles": subtitles } ];
However, I'm not sure how well this works with translations, or if this is the best way to do it.

Another second idea is to use JSON subtitle files, with data similar to the above. We already have .txt subtitle files that go with the video files, but they lack some data, and have absolute screen positions in 640x480 resolution, and are not used consistently (no idea why there are both .txt and .txa files, and they are used interchangeably). JSON seems cleaner and we already have translation scripts for them, but less flexible (no possibility to do dynamic text generation or replacements, for example).

Second, messages are used to make videos available to replay them later during the same mission. The current user interface for this is not terrible (just the code behind it is), but I wonder if we couldn't make it better. Most games now allow you to access all previously played videos, not just those from the current level. (Also, if we allow text to be generated on the fly, we need to store the exact text that was generated. Not a big deal, but would need doing.)

Ideas on this?

User avatar
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Video API

Post by NoQ » 26 Aug 2017, 18:24

Not sure, brainstorming - is it hard use any widespread subtitle format, such as .srt or .ass? Can we simply embed those into the video file as a subtitle track, probably one for each language, and then simply play such videos with some video player library? Because a lot of people are used to translating video subtitles, and it'd be totally friendly to them.
Also, if we allow text to be generated on the fly, we need to store the exact text that was generated.
And that'd be much harder to translate.

Post Reply