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

@goatscrub/videojs-bitmapsub

v1.1.0

Published

A video.js plugin helps you displaying bitmap subtitle type as image, like vobsub (DVD) or pgssub (Bluray).

Downloads

176

Readme

videojs-bitmapsub

A video.js plugin helps you displaying bitmap subtitle type as image, like vobsub (DVD) or pgssub (Bluray).
Test it on demo page.

vobsub

pgssub

Table of Contents

How it works

This plugin can't handle vobsub or pgssub file as-is, you need to generate individual bitmap subtitle image and pack it into large images files. A webvtt metadata track file is used, describing which and when image must be displayed with its cues.
With that description, plugin select corresponding image region from packed subtitles images and display at given time into your video.js player instance.
This repository provide all you need to:

  • extract and pack subtitles images from vobsub or pgssub
  • generate corresponding webvtt metadata file description
  • plugin to handle generated metadata track

NOTE: No OCR (Optical Character Recognition) involved into this process. Again, bitmap subtitles are displayed as images, and they are packed into bigger files only to avoid HTTP traffic, but it's not mandatory.

Usage

Prepare your data

Generate subtitles images packs with corresponding script from tools/ folder.

DVD .vob and .idx files — tools/vobsubpack.php

For DVD subtitles, two files are needed, a .vob and a .idx. With tools/vobsubpack.php you can specify one of them, second one is automaticaly find if they have same base name, only extension differs, eg: vobsub.vob and vobsub.idx.
It's an ugly script wrapper arround sub2png executable. (Why in PHP ?)
This script depend on subp2png binary and bash shell or compatible.

$ ./vobsubpack.php -i tmp/sample_vobsub_file.sub -o web_folder/

$ ./vobsubpack.php -h
vobsubpack.php

 -c    Number of columns, default 4.
 -h    This help description.
 -i    Input vobsub file, .sub or .idx extension
 -l    Number of lines, default 64.
 -o    Output directory
 -v    Print program version.

Bluray pgssub — tools/pgssubpack.py

Relatively slow python script.
Be careful, with default row and column values, pack image can easily have a resolution of 4000 × 6500 pixels, so browser can take time to load it or completely refuse to load too large image. It's specialy visible on image transition, like loading the first subtitle or seeking through video stream.

$ ./pgssubpack.py /tmp/sample.fre.sup -t bitmap-subtitle/
1823 image saved.

$ ./pgssubpack.py -h

usage: pgssubpack.py [-h] [-c COLUMNS] [-d] [-r ROWS] [-l LIMIT] [-t TARGETDIRECTORY] filename

Read PGS (.sup) file and generate pack of subtitles images. You can optionnaly define number of rows and columns.

positional arguments:
  filename

options:
  -h, --help            show this help message and exit
  -c COLUMNS, --columns COLUMNS
                        number of columns within image pack, default: 4
  -d, --debug           temporary files are not remove
  -r ROWS, --rows ROWS  number of rows within image pack, default: 64
  -l LIMIT, --limit LIMIT
                        limit number of subtitle to be processed, for tests purposes
  -t TARGETDIRECTORY, --targetDirectory TARGETDIRECTORY
                        folder destination for files generated

Installation

Install videojs-bitmapsub via npm:

$ npm install @goatscrub/videojs-bitmapsub

Append JS & CSS

Append CSS and javascript into your document.

<link href="//path-plugin/dist/videojs-bitmapsub.min.css" rel="stylesheet" />
<script src="//path-plugin/dist/videojs-bitmapsub.js"></script>

Setting up plugin

Two video.js classical ways, at video.js player creation:

// On player creation
const player1 = videojs('sample', {
  plugins: {
    bitmapsub: { pathPrefix: '/images-subtitles/' }
  }
});

// Passing options directly to plugin
const player2 = videojs('sample');

player2.bitmapsub({ pathPrefix: '/images-subtitles/' });

Plugin options and defaults values

|name|default|description| |----|---|---| |pathPrefix|'/bitmapsub/'|web path to your subtitles packed images files| |labelPrefix|''|menu label prefix| |labelSuffix|' ⋅BMP'|menu label suffix| |name|bitmapsub|instance plugin name|

Append metadata tracks

Bitmapsub plugin search for metadata tracks and filters them by specific label prefix. Label prefix is composed of subtitle_type follow by video_size, separated by colon.
So to be recognized correctly, your label must match format: subtitle_type:video_width:track_label, with subtitle type defined as follow: |type|example|description| |---|---|---| |vobsub|label="vobsub:720:english"|DVD source with video image width 720px and label text english| |pgssub|label="pgssub:1920:français"|Bluray source with video image width 1920px and label text français|

Examples

<!-- DVD -->
<track kind="metadata" label="pgssub:1920:english" language="eng" src="/webvtt-path/file.eng.vtt" />

<!-- Bluray -->
<track kind="metadata" label="pgssub:1920:français" language="fre" src="/webvtt-path/file.fre.vtt" />

What metadata track generated contains

WEBVTT - sample_file.sub

NOTE Video size: 720x576
NOTE File generated with vobsubpack.php 2024-09-05 07:09:37
NOTE Cue format: bitmap-file.png:width:height:driftX:driftY

1
00:00:49.760 --> 00:00:51.239
sample_file.1.vobsub.png 73:22:0:0

[...]

[WIP]

  • settings panel
  • image pre-load
  • moving packing script to RUST and handle both pgssub or vobsub
  • append bitmap subtitles into subscapsmenu
  • menu icon ?

Crédits & inspiration

License

MIT. Copyright (c) goatscrub Ludovic Mabilat