npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

source-caption-compiler

v1.0.2

Published

Compile Source Engine captions

Downloads

12

Readme

source-caption-compiler

A library to compile Source Engine's closed captions from human-readable text source file into the binary format read by the engine. You can use it as an alternative to the usage of Source SDK's built-in caption compiler if it fits your workflow better.

It does not support parsing the binary files back into the textual format (such operation would probably require supplying an array of valid source translation keys, as they're lost in the binary format and converted into CRC-32 checksums of those).

Installation

npm install source-caption-compiler

Usage

import * as fs from "node:fs";
import * as SourceCaptionCompiler from "source-caption-compiler";

const vdf_text = (await fs.promises.readFile("subtitles_english.txt", "utf16le")).toString();
const compiled = SourceCaptionCompiler.compile(vdf_text);
await fs.promises.writeFile("subtitles_english.dat", compiled);

compiled is a Buffer with raw compiled data.

Example files

Example source:

"lang"
{
	"Language" "english"
	"Tokens"
	{
		// Captions defined here.
		"DIAG_TEXT_01" "<clr:255,125,240>A test caption!"
		"DIAG_TEXT_02" "<clr:55,250,240>Another test caption!"
	}
}

Example compiled data:

00000000: 5643 4344 0100 0000 0100 0000 0020 0000  VCCD......... ..
00000010: 0200 0000 0002 0000 bcf2 a075 0000 0000  ...........u....
00000020: 0000 4200 06a3 a9ec 0000 0000 4200 4c00  ..B.........B.L.
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
< ... truncated ... >
000001f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000200: 3c00 6300 6c00 7200 3a00 3200 3500 3500  <.c.l.r.:.2.5.5.
00000210: 2c00 3100 3200 3500 2c00 3200 3400 3000  ,.1.2.5.,.2.4.0.
00000220: 3e00 4100 2000 7400 6500 7300 7400 2000  >.A. .t.e.s.t. .
00000230: 6300 6100 7000 7400 6900 6f00 6e00 2100  c.a.p.t.i.o.n.!.
00000240: 0000 3c00 6300 6c00 7200 3a00 3500 3500  ..<.c.l.r.:.5.5.
00000250: 2c00 3200 3500 3000 2c00 3200 3400 3000  ,.2.5.0.,.2.4.0.
00000260: 3e00 4100 6e00 6f00 7400 6800 6500 7200  >.A.n.o.t.h.e.r.
00000270: 2000 7400 6500 7300 7400 2000 6300 6100   .t.e.s.t. .c.a.
00000280: 7000 7400 6900 6f00 6e00 2100 0000 0000  p.t.i.o.n.!.....
00000290: 0000 0000 0000 0000 0000 0000 0000 0000  ................
< ... truncated ... >
000021f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................

More info on Source's closed captions: https://developer.valvesoftware.com/wiki/Closed_Captions