https://github.com/loctools/subtitle-previewer
https://github.com/loctools/subtitle-previewer
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/loctools/subtitle-previewer
- Owner: loctools
- License: mit
- Created: 2021-03-21T02:27:46.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-21T02:39:15.000Z (over 5 years ago)
- Last Synced: 2025-01-21T09:29:07.474Z (over 1 year ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES
- License: MIT-LICENSE.txt
- Authors: AUTHORS
Awesome Lists containing this project
README
# Subtitle Previewer
This is a subtitle previewer application that works directly in the browser (it doesn't require any server-side component), and is meant to be used as an in-context previewer when editing subtitles inside a CAT tool.
# Installation
You can host it anywhere (on S3, or as a static Github page). Just publish the contents of the `previewer` folder somewhere where it can be accessed by a public URL.
# Usage
Provided you have published the Subtitle Prevewer under `https://example.com/previewer` URL, you can run it as follows:
https://example.com/previewer/index.html#jsonp={JSONP_URL}[&hl={N}][&play]
where
- `JSONP_URL` is a URL of a subtitle file in a special format (see below), which can be hosted anywhere.
- `hl={N}` is an optional parameter, where `N` is the index of a cue to highlight and navigate to.
- `play` is an optional parameter, which instructs the highlighted cue to auto-play upon loading.
# JSONP Subtitle Data Format
This is a special format that allows one to reference the cue data across domains. It contains of a `jsonp( ... );` wrapper function with some JSON data inside. `cues` is an array of cues, and `mediaUrl` is a URL of a media file to be rendered. It can be a video file (`.mp4`) or an audio file (`.mp4`). If not provided, a blank video will be used. Each cue has `from` and `till` timestamps encoded as offsets from the beginning of the track, in milliseconds. `text` is what is being displayed on top of the video.
```javascript
jsonp(
{
"mediaUrl" : "https://static.storage.site/path/to/video.mp4",
"cues" : [
{
"from" : 4035,
"text" : "Text of the first cue",
"till" : 9099
},
{
"from" : 10043,
"text" : "Text of the second cue",
"till" : 12062
},
...
]
}
);
```
# Questions / Comments?
Join the chat in Gitter: https://gitter.im/loctools/community