arnavion / libjass Goto Github PK
View Code? Open in Web Editor NEWRenders ASS subs in the browser.
License: Apache License 2.0
Renders ASS subs in the browser.
License: Apache License 2.0
M{\fry60}N{\fry60}O
will cause O to be rotated a total of 60 degrees, not 120.M{\frz45\fry60}N{\fry0}O
, M will be rotated by 0-0-0, N will be rotated by 60-0-45 and O by 0-0-45All these facts combined mean that rotations must nest. The line M{\frz45\fry60}N{\fry0}O{\frx90\frz30}P
must be rendered as follows:
<span id="1">M<span id="2">N<span id="3">O<span id="4">P</span></span></span></span>
with the following transforms on each:
#1: .transform = "";
#2: .transform = "rotateY(60deg) rotateX(0deg) rotateZ(-45deg)";
#3: .transform = "rotateZ(45deg) rotateX(-0deg) rotateY(-60deg) " + // undo existing rotation to reset back to 0
"rotateY(0deg) rotateX(0deg) rotateZ(-45deg)"; // apply new rotation
#4: .transform = "rotateZ(45deg) rotateX(-0deg) rotateY(-0deg) " + // undo existing rotation to reset back to 0
"rotateY(0deg) rotateX(90deg) rotateZ(-30deg)"; // apply new rotation
The only thing that should start a top-level span with no reversed rotation applied first is a \N
Unfortunately browsers implement rotation in a retarded manner. All rotations are done from scratch, i.e., if the parent element is rotated, the child element's rotation is not applied on top of the parent's rotation. Instead, it's applied as if the way the child is visible right now is the 0-0-0 state. Thus there is no way to undo a parent's rotation on a child and apply a new rotation.
<style type="text/css">div { display: inline-block; }</style>
<div><div>ABCD</div></div>
<div style="-webkit-transform: rotateY(60deg); transform: rotateY(60deg);"><div>ABCD</div></div>
<div style="-webkit-transform: rotateY(60deg); transform: rotateY(60deg);"><div style="-webkit-transform: rotateY(-60deg); transform: rotateY(-60deg);">ABCD</div></div>
Notice how the third div doesn't look like the first. The child doesn't have the parent's 60deg rotation reversed, instead it has a -60deg rotation applied to its appearance due to the parent rotation (second div).
Another example: http://jsfiddle.net/ag5dQ/4/ Notice how .child_b1
is the same size as .child_b
, but .child_b2
isn't.
The demo gives the error "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied" when making XHR requests in Firefox when opening the page locally.
... and move the custom font instructions to the JSDoc on RendererSettings.makeFontMapFromStyleElement
Seems like proportion is right but whole text becomes much bigger than should be.
Test script:
[Script Info]
Title:
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
Scroll Position: 0
Active Line: 0
Video Zoom Percent: 1
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Trebuchet MS,54,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,2.55,0,2,0,0,42,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:10:00.00,Default,,0,0,0,,{\fscx50}xxxxxxxxxxxxxxxxx
Dialogue: 0,0:00:00.50,0:10:00.00,Default,,0,0,0,,{\fscy50}yyyyyyyyyyyyyyyyy
Looks like there is a JavaScript error preventing the library from loading up on Safari. I was able to reproduce by just loading the demo page.
I'm running Safari Version 8.0.3 (10600.3.18) on OS X Yosemite 10.10.2 (14C109).
Let me know what other information you might need to take a look.
The fix for #52 introduced multiplying the SourceAlpha by 1e6 to try to get the equivalent of SourceAlpha but with value 1 at all points instead of the actual source value. This has the downside that the result is blocky and slightly larger than the source, so not only are the outer edges of the outline blocky, but excluding the multipled alpha from the outlines leaves a noticeable clear gap around the source.
Test script:
[Script Info]
Title:
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
Scroll Position: 0
Active Line: 0
Video Zoom Percent: 1
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Trebuchet MS,54,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,2.55,0,2,0,0,42,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0,0,0,,Should be on bottom 1
Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0,0,0,,Should be on top 1
Dialogue: 0,0:00:04.00,0:10:00.00,Default,,0,0,0,,Should be on bottom 2
Dialogue: 0,0:00:05.00,0:10:00.00,Default,,0,0,0,,Should be on top 2
P.S. Test almost the same as #48 but this issue about different thing so I decided to put it in separate issue.
Calling this.disable()
first sets this._enabled
to false, then calls this.pause()
which does nothing because this._enabled
is false, then calls this.stop()
, which works as expected and makes WebRenderer
hide the subtitle container by dispatching ClockEvent.Stop
.
Then calling this.enable()
, sets this._enabled
but subsequent this.tick()
calls call this.play()
which doesn't send the ClockEvent.Play
event, because it isn't this._paused
is false (the this.pause()
call during this.disable()
did nothing). Since no ClockEvent.Play
is received WebRenderer
doesn't restore the visibility of the subtitle container.
What I would expect to work:
webRenderer.disable();
webRenderer.enable();
What's actually needed:
webRenderer.disable();
webRenderer.enable();
manualClock.pause();
manualClock.play();
Also an enabled property, and .toggle() to toggle.
For example, Style defaults fontName to sans-serif
if the ASS doesn't specify one. Such a keyword is supposed to be used without quotes for the CSS font-family
property, otherwise it's interpreted as a real font name instead of a keyword.
Either:
or
The drawing should be scaled to 1 / Math.pow(2, this._drawingScale - 1)
instead of 1 / this._drawingScale
Test script:
[Script Info]
Title:
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
Scroll Position: 0
Active Line: 0
Video Zoom Percent: 1
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Trebuchet MS,54,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,2.55,0,2,0,0,42,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0,0,0,,Should be on bottom 1
Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0,0,0,,Should be on top 1
P.S. Test almost the same as #49 but this issue about different thing so I decided to put it in separate issue.
rate: number
, and ManualClock will need a setter setRate(rate: number)
This would make a scenario where subtitles are being generated during playback (i.e. live or live-transcoded streams) much easier.
Style.OutlineWidth -> OutlineThickness
{parts, SpanStyles}.OutlineWidthX -> OutlineWidth
{parts, SpanStyles}.OutlineWidthY -> OutlineHeight
When going fullscreen on chrome, subtitles moves, are not visible or are in wrong position, on firefox everything works ok.
SunnyLi/videojs-ass#1
fscx scaling via transform: scaleX(...)
causes the scaled text to clip its neighbors. One alternative is to do the following transformation:
Given:
fontSize = f
fontScaleX = x
fontScaleY = y
Transform to:
fontSize = f * x
fontScaleX = 1
fontScaleY = y / x
and drop the scaleX(...)
The problem is that lines like This does not happen.{\fs12\fscx1000\fscy100}
(f = 12, x = 10, y = 1 => f = 120, x = 1, y = 0.1) will end up having a line height of 120px; the 0.1 vertical scaling will not allow the line height to be set to 12px.
libjass with enableSvg = true:
libjass with enableSvg = false: (notice that it darken than previous, it more noticeable on colored text)
Script:
[Script Info]
Title:
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Trebuchet MS,54,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,2.55,0,2,0,0,42,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 1,0:00:00.00,0:00:36.95,Default,,0,0,0,,{\alpha&7E&}test
Maybe just remove rgba from "color" and "text-shadow" and add "opacity". I tried it via debugger and seems like everything is okay.
For example replace:
color: rgba(255, 255, 255, 0.686275);
text-shadow: rgba(19, 7, 2, 0.686275) 0px 0px 0px, ...many shadows...;
to:
opacity: 0.686275;
color: rgb(255, 255, 255);
text-shadow: rgb(19, 7, 2) 0px 0px 0px, ...many shadows...;
Or is there some kind of pitfall?
At least until https://bugs.webkit.org/show_bug.cgi?id=137856 is fixed, and it's been in radar since October with no sign of a solution any time soon.
My use case is I use torrent-stream, which creates readable streams of torrent files. You can start watching video files, before they are fully transferred. I can also feed a mkv video file stream into ffmpeg to create a ASS file stream. It would be neat if libjass could support rendering the currently parsed dialogue.
I looked around and it seems like I could create my own versions of ASS.fromURL
& ASS.fromStream
to return the minimalAss
promise instead. I didn't see if using that would work yet and the renderer was too complex to figure out for me for now.
Anyways, if libjass could support this use case that would be super. If modified ASS.fromURL
& ASS.fromStream
is all that's needed for it to work, I'll send a pull request.
For compatibility with the official API (and browsers' native implementations). I think this should be a couple extra prototypes in the interface section and a 1-line wrapper function.
animation-timing-function: step-end
With a paused clock, animations are paused. WebRenderer.draw is a no-op because the dialogue is already drawn. As a result, the sub animation remains paused at the frame it was first drawn at instead of updating with the ticks.
Happens often when playing video with heavy animation (heavy for libjass, fine in native player). Also that happens on regural subtitles on mobile devices (such as Chrome on Android tablet). In case of network lag (html5 player waiting for video to load) that happens too.
These delays started after implementing new AutoClock. AutoClock take value of currentTime from html5 video only once. So difference between time in AutoClock and currentTime in html5 video growing and growing. Re-sync of timing happens only if seek to other part of video. It doesn't happens on play & pause.
Maybe sync time each "onupdatetime" event? (but there may be noticeable gaps, not sure)
BTW, why you decided to switch from "onupdatetime" to manual clock only?
Animated \alpha start animation from 0% opacity while should start it from 100% opacity.
Test script:
[Script Info]
Title:
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Trebuchet MS,54,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,2.55,0,2,0,0,42,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 1,0:00:00.00,0:00:36.95,Default,,0,0,0,,{\t(2000,5000,\alpha&7E&)}test
See libass's string2color: https://github.com/libass/libass/blob/master/libass/ass_utils.c#L170
This effectively means assuming missing digits at the start are 0. There are all sorts of weird nuances of color parsing, but this one's pretty common as ffmpeg outputs it:
Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
http://docs.aegisub.org/manual/Properties
WrapStyle
ScaledBorderAndShadow
This would be useful for cases where the consumer wants to manage coarse time events manually, but doesn't want to duplicate VideoClock's fine-grained update code.
Test script:
[Script Info]
Title:
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
Scroll Position: 0
Active Line: 0
Video Zoom Percent: 1
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Trebuchet MS,54,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,2.55,0,2,0,0,42,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:10:00.00,Default,,0,0,0,,{\fs50\frz22.962\fscx180\pos(812.95,394)}1111111111111111111111111111111111
Dialogue: 0,0:00:00.00,0:10:00.00,Default,,0,0,0,,{\fs50\frz22.962\pos(812.95,394)}2222222222222222222222222222222222222
var libjass = require("libjass");
libjass.version; // ["1.0.0", 1, 0, 0]
hello
i have two problem after using libjass on website
the first is about support fonts
i think the pre-loading not work properly
i have all the font in my pc and also i have attached font to the script
but here photo of what appears
in libass
http://im49.gulfup.com/8NvrgU.png
in libjass
http://im49.gulfup.com/Bp3V1O.png
the second problem with font size... sometimes become smaller and sometime bigger
here in libass
http://im49.gulfup.com/8NvrgU.png
and here in libjass
http://im49.gulfup.com/Yn5u5K.png
[Script Info]
; Script generated by Aegisub 2.1.8
; http://www.aegisub.org/
Title: العربية
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
YCbCr Matrix: TV.601
Last Style Storage: rapu
Video File: ?dummy:23.976000:40000:1280:720:47:163:254:c
Video Aspect Ratio: 0
Video Zoom: 3
Video Position: 33204
[Aegisub Project Garbage]
Audio File: ../../274 [720p].mkv
Video File: ../../274 [720p].mkv
Video AR Mode: 4
Video AR Value: 1.777778
Video Zoom Percent: 0.250000
Scroll Position: 146
Active Line: 152
Video Position: 830
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Adobe Arabic,63,&H00FFFFFF,&H00FFFFFF,&H00020203,&H00000000,-1,0,0,0,104.274,100,0,0,1,1.7,0.74,2,21,21,30,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:01:55.90,0:01:58.19,Default,,0000,0000,0000,,!عليّ أن أسأل أحد شينوبي السحاب حول طريقة استعمالها
Hi, i'm relatively new to Javascript, i've seen the ''online demo'', it works fine, but the script is too complex to understand and edit, is it possible a simple ''hello world script''?
Something like:
-script-
var video = VIDEO_URL
var sub = ASS_URL
//SOME CODE TO RUN LIBJASS on idvideo
-/script-
-video id='idvideo'- -/video-
Thanks for attention
Any chance that you'll create a bower package or check in the compiled libjass.js
and libjass.css
?
libjass is more front-end centric and having a compiled version of the essential files will simplify dependency management of other front-end projects using libjass.
Checking in the compiled files for every new tag/release would be great.
Thanks
http://docs.aegisub.org/manual/Styles
SecondaryColour - Karaoke
Angle - ?
BorderStyle - 1 for normal outlines, 3 for "opaque box"
This works:
[Script Info]
; Script generated by FFmpeg/Lavc56.12.100
ScriptType: v4.00+
PlayResX: 384
PlayResY: 288
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:02.96,0:00:06.40,Default,,0,0,0,,That's my vehicle\Nand I want it back!
This does not:
[Script Info]
ScriptType: v4.00+
PlayResX: 384
PlayResY: 288
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,1,1,0,2,10,10,10,0,0
[Events]
Format: Layer, Start, End, Style, Text
Dialogue: 0,0:00:02.88,0:00:06.32,Default,That's my vehicle\Nand I want it back!
It produces output like this:
It looks like a number of style attributes don't output.
Outline looks pretty wrong/ugly after Chrome update. Probably that caused by new way of rendering fonts in Chrome (now chrome uses Direct Write as I understand).
Screenshot (in Chrome):
Screenshot (in Firefox):
Screenshot (in Aegisub):
Test script:
[Script Info]
Title: Test
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 1280
PlayResY: 720
ScaledBorderAndShadow: yes
YCbCr Matrix: TV.601
Last Style Storage: Default
Scroll Position: 0
Active Line: 0
Video Zoom Percent: 1
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Main,Arial,42,&H00FFFFFF,&H000000FF,&H00331B2F,&H00000000,-1,0,0,0,100,100,0,0,1,1.8,0,2,20,20,35,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:10:00.00,Main,,0,0,0,,Lorem ipsum dolor sit amet
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.