Closed Captions: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Compiling: alternative method)
No edit summary
Line 1: Line 1:
<div style="margin:1em auto;max-width:55em;background:#FF9F9F;padding:.5em;font-size:1.4em;border:1px solid #FF3F3F;">
<div style="margin:1em auto;max-width:55em;background:#FF9F9F;padding:.5em;font-size:1.4em;border:1px solid #FF3F3F;">
<strong style="color:#FF0000;">Please note:</strong> The caption compile tool [http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=111 is not currently available in the SDK]. It will be included in the next release; until then, [http://steamreview.org/external/vdc/captioncompiler.zip it can be downloaded here.]</div>
<strong style="color:#FF0000;">Please note:</strong> The caption compile tool [http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=111 is not currently available in the SDK]. It will be included in the next release; until then, [http://steamreview.org/external/vdc/captioncompiler.zip it can be downloaded here.]
 
The tool only seems to work with -engine ep1 in the Source SDK configuration so switch to it temporaily <span style="font-size: 0.7em">(still I don't know if the closed captions will work)</span>.</div>
__NOTOC__
__NOTOC__
'''Closed captions''', or subtitles, are text descriptions that accompany sound and dialogue. Their primary use is to enhance accessibility for users with audio-related difficulties, be it a disability, a hardware problem, or simply noisy surroundings, though with a bit of ingenuity they can also be used to display dialogue that has not been recorded. They can be enabled in the Source engine in the Audio tab of the Options dialogue box.
'''Closed captions''', or subtitles, are text descriptions that accompany sound and dialogue. Their primary use is to enhance accessibility for users with audio-related difficulties, be it a disability, a hardware problem, or simply noisy surroundings, though with a bit of ingenuity they can also be used to display dialogue that has not been recorded. They can be enabled in the Source engine in the Audio tab of the Options dialogue box.

Revision as of 10:17, 23 February 2008

Please note: The caption compile tool is not currently available in the SDK. It will be included in the next release; until then, it can be downloaded here.

The tool only seems to work with -engine ep1 in the Source SDK configuration so switch to it temporaily (still I don't know if the closed captions will work).

Closed captions, or subtitles, are text descriptions that accompany sound and dialogue. Their primary use is to enhance accessibility for users with audio-related difficulties, be it a disability, a hardware problem, or simply noisy surroundings, though with a bit of ingenuity they can also be used to display dialogue that has not been recorded. They can be enabled in the Source engine in the Audio tab of the Options dialogue box.

Editing closed captions

Closed captions are stored in closecaption_%language%.txt (e.g. closecaption_english.txt) in the resource/ folder of a mod, though Source will only read from a corresponding .dat file. The caption files for Half-Life 2 can be found in source engine.gcf under root/hl2/resource/. Extract it using GCFScape for editing.

The format of the file is:

lang
{ 
	Language "English" //(or "French", etc)
	Tokens 
	{ 

		// Captions defined here.
		nameofcorrespondingsound	"This is the caption."
		barn.chatter	"We're picking up radio chatter. They're looking for your car. "
		// ...

	}
}

As indicated, the first half of a caption-defining line is the name of a sound token. This should correspond to a sound defined in one of the sound files listed in modname/scripts/game_sounds_manifest.txt. E.g. barn.chatter is defined in hl2/scripts/level_sounds_coast.txt. You need to use "quote marks" if a single entry contains a space.

Compiling

The captions must be compiled with captioncompiler.exe. Simply drag your caption file onto it.

This process will be easier if you create a batch command file in the resource folder. Copy the following code into a text file and name it "something.cmd":

"%sourcesdk%\bin\ep1\bin\captioncompiler.exe" %1
pause

Drag your caption .txt files onto the CMD to use it. Remember to replace ep1/ with orangebox/ if needed!

Alternative compilation method

To output the compiled .dat file, you can also try the following:

  1. Save captioncompiler.exe under <username>\sourcesdk\bin\ep1\bin\captioncompiler.exe
  2. Place the closecaptions_english.txt in <username>\portal\portal\resource
  3. In DOS, cd (browse) to the compiler's location.
  4. Type captioncompiler -v closecaption_english.txt and hit Enter
  5. The output closecaption_english.dat file is available under <username>\portal\portal\resource

Using closed captions with no attached dialogue or sounds

Recording dialogue is a very resource-expensive process. If, once dialogue has been recorded, you decide you want to change something, making those changes can prove very costly, so final dialogue recording is often best done as one of the final stages in a project.

However, while creating choreographed scenes, it is highly desirable to have the dialogue available as early as possible. One way around this conflict is for the developer to record their own placeholder audio, but even this can take up significant amounts of time. A cheaper way of creating placeholder dialogue is to use closed captions without any attached dialogue.

There are three steps involved in accomplishing this:

1. Creating the captions
Sound tokens (e.g. barn.chatter above) can have closed captions attached without corresponding entries in the sound manifest. To create new closed captions, simply add new entries to the closecaption_english.txt (or other language file), as described above.
2. Adding the captions in Faceposer
In Faceposer, dialogue-free closed captions are added in the same way normal dialogue is added (right-click on the timeline and choose WAV File...). However, because the closed caption tokens are not in the sound manifest, they will not appear on the list of available sounds. Instead, simply refer to the entries you added in step 1 and type the token name manually into the Sound textbox.
3. Setting the length of caption appearance time
Once the first two steps are complete, your scenes will display the closed captions when they are played in game (as long as closed captions are turned on in the game options, of course). However, because there is no associated sound file, the event has no length. This means that the closed captions will leave the screen almost as soon as they are displayed, leaving a player little time to read them. While this is acceptable for captions comprised of one or two words, some more work is required to keep longer captions up on screen for a sufficient amount of time.

Faceposer doesn't support editing the length of WAV file events, but they can be edited through manual editing of the .vcd file. Open the .vcd in Notepad and find the speak event you wish to change the length of. A search for the name of the speak event will take you to the right place in the file.

There you will find an entry like this one:

event speak "Test"
{
	time 1.000000 -1.000000
	param "test.test"
	fixedlength
	cctype "cc_master"
	cctoken ""
}

The time line denotes the start and end time of the event. The end time is set to -1.000000 because the speak event currently has no length. Edit this number to be the time (in seconds, on the timeline) when you wish the closed caption to end and save the file.

Obviously the desired length of time that a caption appears for will differ depending on the length of text. In general, when trying to decide how long text should appear on screen for, a good first estimate can often be achieved by timing yourself reading the text aloud and then doubling that number, to account for its unfamiliarity to fresh eyes.

Note.pngNote:You may find it useful to include a logic_auto and a point_clientcommand in your map, set to issue the console command closecaption 1 on map load. This will ensure that you don't need to remind anyone using your mod (e.g. other team members) to turn on their captions.
Warning.pngWarning:As a final note, this method could charitably be described as "experimental" and less charitably as a hack. As with all hacks, there exists the possibility that unpredictable and unexpected behaviour will be introduced. It is recommended that you make backups of your .vcd's before manually editing them, and keep regular backups of your .vcd's, lest Faceposer undo those edits suddenly.

See Also