隐藏式字幕

From Valve Developer Community
Jump to: navigation, search
English 简体中文
《半条命 2》中的隐藏式字幕。布林博士预先录制的演讲没有很清晰,因为它没有那么重要。

隐藏式字幕,或者字幕,是伴随声音和对话而出现的文本描述。它们可以提示那些听力存在障碍的玩家,在一定程度上也提示玩家周围正在发生什么。通过一些巧妙的设计,它们还可以用来显示尚未录制的对话。

可以在起源引擎游戏的“选项”>“音频”里启用对话字幕或者完全字幕。

声音脚本scripts/sentences.txt中定义的声音都可以制作成字幕。

编辑隐藏式字幕

Closed captions are stored in closecaption_%language%.dat (e.g. closecaption_english.dat) in <game dir>\resource\. A .dat file is binary file compiled from a corresponding .txt file by the captioncompiler tool.

Although the engine does not read from the text file, Valve provided their originals for use by modders. You can find them in your resource\ folder or possibly in the VPKs.

文本文件的格式为:

lang
{ 
	Language "English" //设置为“英语”(或者“schinese”代表简体中文,以及其他语言...)
	Tokens 
	{ 
		//这里开始编写字幕。
		音效名称	"这是字幕文本。"

		barn.chatter	"We're picking up radio chatter. They're looking for your car."
		//以此类推...
	}
}
  • 文本文件必须以“UCS-2 Little Endian”的编码格式保存。
  • 音效名称必须是在你的音效脚本里定义的音效,而不是音频的原始文件名。
  • 记得在有空格的数据块两边加上英文双引号。


以下是一个 sentences.txt 的例子:

音效名称 声音文件 {字幕代码 closecaption 音效名称}

BA_LATE barney/c1a0_ba_late {Len 2.33 closecaption BA_LATE}

字幕代码

<sfx>
把字幕标记为音效字幕,只能在“显示完全字幕”启用的情况下出现。如果玩家将 cc_subtitles 设置为“1”,就不会出现这些字幕。
<clr:255,255,255>
使用 RGB 设置字幕的颜色,0 表示无色,255 表示全色。比如<clr:255,255,255>表示白色。
<playerclr:255,176,0:255,255,255>
基于是否由玩家/客户端发出的声音来设置 RGB 颜色。第一个颜色代码是当音效为玩家所发出时,字幕的颜色。第二个颜色代码是当音效为非玩家所发出时,字幕的颜色。用冒号分隔。举个例子,<playerclr:255,176,0:255,255,255>当声音是由玩家或玩家的武器发出的,字幕为橙色,由其它东西发出的,为白色。
<B>
加粗该标记后面的所有文本。
<I>
将标记后面的文本变成斜体。
Note.png Note: <B><I> 都可以在同一行内取消。"这是<B>粗体!<B>这是非粗体。" 看起来就像这样:这是粗体!这是非粗体。
<norepeat:15>
控制字幕出现的频率。如果设置为 15,则表示这行字幕在出现后 15 秒之内不会重复出现。
<len:5>
设置字幕的持续时间。举个例子,<len:5>会让字幕在屏幕上持续 5 秒钟。如果不添加此代码,字幕的持续时间为“音频时长+cc_linger_time命令的参数”。
<cr>
为字幕手动添加一个空行。
举个例子,"功能:<cr>字幕"等同于
功能:r:es
字幕
<delay:2>
设置字幕文本出现的延迟,自动换行并且清除所有格式。举个例子,在“<i><clr:255,176,0>HEV 已启动。<delay:3>你的 HEV 已经启动。”中,“HEV 已启动”将会以橙色斜体的样子出现。3 秒钟后,“你的 HEV 已经启动”将出现在它下面,而不使用上一行的任何格式。新行总是在前一行的正下方,即使下面有其他字幕。

编译

字幕文件必须使用 captioncompiler.exe 进行编译。且需要编译的字幕文件必须位于模组的 resource 文件夹,这样才能够生成 .dat 文件。 举个例子 C:\Program Files\Steam\steamapps\SourceMods\[模组名称]\resource\,如果在 resource 文件夹中创建批处理命令文件,此过程将变得稍微容易一些。将以下代码复制到文本文件中,并将其另存为 .bat 文件:

"C:\Program Files (x86)\Steam\steamapps\common\Half-Life 2\bin\captioncompiler.exe" %1
pause
Tip.png 小技巧: With a batch file, you can use the -game "path to mod folder" parameter to override the global vproject value. Place it after %1, leaving a space. This saves you from having to launch the SDK and change it there.
Note.png 注意: All the filepaths in this file should be absolute, meaning they start at C:\.
Note.png 注意: Depending on the engine branch, one might change the location of the exe indicated at the batch file into other folders, as the compiled .dat file might not be compatible with such version.

Drag your caption .txt files onto the Batch file to use it as you would the .exe itself.

在你的地图里播放带有字幕的音频

Sometimes, you may want to play a sound with closed captions (or subtitles, really) when the player activates a trigger. Unfortunately, ambient_generic's "Play Everywhere" flag is broken for soundscripts, and subtitles only work on soundscripts and in sentences.txt (except for commentary nodes, see here). Hence you'll have to do a bit of a hack: use point_clientcommand to execute three commands:

  • play path/to/sound/file
  • cc_linger_time X, where X is a manually-tweaked value.
  • cc_emit commentaryFileName, where commentaryFileName is a key from the closed captions text file.

Make sure both closecaption 1 and cc_subtitles 1 are set.

没有音频的字幕

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.png 注意: 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.png 警告: 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.

为 BINK 视频制作字幕

随着《Left 4 Dead 求生之路 》的发布,现在可以为 Bink 视频制作字幕。

注意事项

Left 4 Dead 2 求生之路 2 以及之后的游戏中,Valve 使用 subtitles_language 作为字幕文件for the subtitles instead of keeping them in the closecaption_language files with the "hearing impaired" captions. The probable reasoning for this is because "closed captions" is for the hearing impaired, and for convenience. "Subtitles" is a more accepted term to use for this entity's purpose. Though, the sounds can still be marked as <sfx>.

另见