Fetch the repository succeeded.
ASS.js uses ass-compiler to parse ASS subtitle file format, and then renders subtitles on HTML5 video.
ASS specs(zh-Hans)
npm install assjs
<video id="video" src="example.mp4"></video>
<script src="dist/ass.min.js"></script>
<script>
fetch('/path/to/example.ass')
.then(res => res.text())
.then((text) => {
const ass = new ASS(text, document.getElementById('video'));
});
</script>
const ass = new ASS(text, video, {
// Subtitles will display in the container.
// The container will be created automatically if it's not provided.
container: document.getElementById('my-container'),
// see resampling API below
resampling: 'video_width',
});
If you change the size of video, you should call it.
ass.resize();
ass.show();
ass.hide();
ass.destroy();
When script resolution(PlayResX and PlayResY) don't match the video resolution, this API defines how it behaves. However, drawings and clips will be always depending on script origin resolution.
There are four valid values, we suppose video resolution is 1280x720 and script resolution is 640x480 in following situations:
video_width
: Script resolution will set to video resolution based on video width. Script resolution will set to 640x360, and scale = 1280 / 640 = 2.video_height
(default): Script resolution will set to video resolution based on video height. Script resolution will set to 853.33x480, and scale = 720 / 480 = 1.5.script_width
: Script resolution will not change but scale is based on script width. So scale = 1280 / 640 = 2. This may causes top and bottom subs disappear from video area.script_height
: Script resolution will not change but scale is based on script height. So scale = 720 / 480 = 1.5. Script area will be centered in video area.ass.resampling = 'video_width';
Items with strikethrough means they won't be supported.
\N
in Aegisub has less height than <br>
in browsers, subbers should avoid to use multiple \N
to position a dialogue, use \pos
instead.\t
is not rendered correctly, for transforms in browsers are order-sensitive.\move
at the same time, only \move
works.clip-path
CSS property to implement \clip
, IE and Edge are not supported yet.\be
is just treated as \blur
.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。