libass / JavascriptSubtitlesOctopus

Displays subtitles in .ass format from JavaScript. Supports most SSA/ASS features, easily integrates with HTML5 videos.
MIT License
412 stars 104 forks source link

update libass or add harfbuzz !! #9

Closed anoosi closed 6 years ago

anoosi commented 7 years ago

hi, i used right to left language [ arabic ], and libass doesn't support all the character for all language rtl, i tried to add harfbuzz and compile it but i get error in build, for now i used SubtitlesOctopus in other language but for arabic [rtl] language libass doesn't . harfbuzz is a best solution for this issue, and for all rtl languages, if you would can make another version of SubtitlesOctopus with harfbuzz that would be highly great, thanks

anoosi commented 7 years ago

or at least update libass to last version in libass 0.13.3 they make a good update for rtl language , look at this issue https://github.com/libass/libass/issues/224 so all i need is just update to libass, to solve rtl issues. thanks.

anoosi commented 7 years ago

i get error in compile

cd build/fribidi && \
git reset --hard && \
patch -p1 < ../fribidi-make.patch && \
touch configure.ac aclocal.m4 configure Makefile.am Makefile.in && \
aclocal && autoconf && autoheader && automake --add-missing && \
emconfigure ./configure \
    CFLAGS=-O3 \
    NM=llvm-nm \
    --prefix="$(pwd)/dist" \
    --disable-dependency-tracking \
    --disable-debug \
    --without-glib \
    && \
emmake make -j8 && \
emmake make install
HEAD is now at 1a6935c 0.19.7
patching file Makefile.am
patching file gen.tab/Makefile.am
lib/Headers.mk:22: warning: shell cat $(top_srcdir: non-POSIX variable name
lib/Headers.mk:22: (probably a GNU make extension)
doc/Makefile.am:26:   'lib/Headers.mk' included from here
lib/Headers.mk:22: warning: shell cat $(top_srcdir: non-POSIX variable name
lib/Headers.mk:22: (probably a GNU make extension)
lib/Makefile.am:28:   'lib/Headers.mk' included from here
test/Makefile.am:30: warning: '%'-style pattern rules are a GNU make extension
/bin/sh: 6: emconfigure: not found
Makefile:95: recipe for target 'build/fribidi/dist/lib/libfribidi.so' failed
make: *** [build/fribidi/dist/lib/libfribidi.so] Error 127

how do it correctly ?

Dador commented 7 years ago

Looks like you didn't installed EMSDK. If you installed it and still getting error then probably you didn't activated it using command like source ./emsdk_env.sh.

I'm planning to try out harfbuzz in future and compare speed to fribidi. Also I have plans to upgrade libass. But not sure when that future will be :)

anoosi commented 7 years ago

i activated but i get error through compiling.. so in the last i edit the font fontcreator v11 and everything now ok.. but it need to edited every font i use! for now i will managed this issue through edit fonts and i will waiting new update thanks..

anoosi commented 7 years ago

checking for rand_r... yes checking for readlink... yes checking for fstatvfs... yes checking for fstatfs... yes checking for lstat... yes checking for posix_fadvise in fcntl.h... fcntl.h checking for struct statvfs.f_basetype... no checking for struct statvfs.f_fstypename... no checking for struct statfs.f_flags... yes checking for struct statfs.f_fstypename... no checking for struct dirent.d_type... yes checking for FREETYPE... no configure: error: Package requirements (freetype2) were not met:

No package 'freetype2' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

Alternatively, you may set the environment variables FREETYPE_CFLAGS and FREETYPE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. Makefile:77: recipe for target 'build/fontconfig/dist/lib/libfontconfig.so' failed make: *** [build/fontconfig/dist/lib/libfontconfig.so] Error 1

any idea ?

Dador commented 7 years ago

any idea ?

You could try to run make clean before running make (maybe you have cached paths). And if that doesn't helps, please send gist with full log.

I've updated libass to latest version. could you check it again? But not sure that it'll help because the commit you linked before was already included in version of libass we had before.

Also, can you send a small .ass file to check the issue?

anoosi commented 7 years ago

thanks for updating i checked but the same problem :( I am going to explain things. first one in adobe arabic font in libass without harfbuzz "ألّا يَجِب عليكَ الذهاب هذه المرّة؟" libass

and this in vsfilter is the same result in libass with harfbuzz vsfilter

in libass without harfbuzz the character "ه" it's changed to "هـ" and "ألّا" it's changed to "ألّـا" and that wrong The character ﻻ is a combination of two letters, ل and ا . When these two letters come beside each other, they are replaced by the ﻻ character.

in vsfilter or libass with harfbuzz is appears no problems 100% i tested https://github.com/dead/libass.js/ it's libass with harfbuzz but the problem this lib consume a lot of memory. but i prefer JavascriptSubtitlesOctopus it's consume less memory and faster .

another font Arabic Typesetting libass libass2

vsfilter vsfilter2

all the others fonts not like "adobe arabic" fonts! it's like "Arabic Typesetting" in libass and it's make space between character if exist ّ َ ً ُ ٌ ِ ٍ
but in vsfilter or libass with harfbuzz there no problem at all

you can see this comparison https://imgur.com/a/p9wJB

to be informed, this problem in Arabic, Urdu and Persian languages and maybe in others languages RTL

this script+fonts script+fonts.zip

Dador commented 7 years ago

Thanks for explanation and test files.

I'll try to build with harfbuzz when I'll have time. Looking at https://github.com/dead/libass.js/ that shouldn't be a problem.

anoosi commented 7 years ago

for https://github.com/dead/libass.js/ there is no problem at all in the fonts.. but as i said before it's consume a huge memory ..

JavascriptSubtitlesOctopus in chrome or firefox around 230-260mb libass.js consume 440-500mb! and thats too huge and another things make me prefer JavascriptSubtitlesOctopus like fontselect.. etc..

it would be great if you make another branch build with harfbuzz .. until then if you don't have a comment, you can close this issue..

thanks..

Dador commented 7 years ago

500MB (and 260MB too) for subtitles, modern world, heh 😄

I'm planning to use harfbuzz as main one (if there is no performance disadvantage). I don't close issue as it's still not resolved and I'm planning to do so.

anoosi commented 7 years ago

there is libjass and it's a good but it's didn't support all tags and some issues. yes (JavascriptSubtitlesOctopus and libass.js) is too future but i think it's work like charm :100: ..

Dador commented 7 years ago

Yeah, I know about libjass. I worked a little bit with it before. In one of issues, Arnavion wrote thoughts about using asm.js and that's where the idea of this project comes from.

anoosi commented 7 years ago

yes, in fact i found out JavascriptSubtitlesOctopus through one of your comments in one of issues in libjass :laughing:

dead commented 7 years ago

Great job with JavascriptSubtitlesOctopus 😄

Not sure why libass.js consumes more memory than JavascriptSubtitlesOctopus. It should be the same... The only diference is the harfbuzz. But maybe I'm leaking memory somewhere...

I was testing JavascriptSubtitlesOctopus with this test subtitle (railgun opening with krk fx) and it crashed. It is a super heavy subtitle that I use to benchmark. I had the same problem when compiling with Web Assembly in libass.js and it can be fixed using -s "BINARYEN_TRAP_MODE='clamp'".

I also would like to suggest to use requestFrameAnimation instead setTimeout in JavascriptSubtitlesOctopus. It does use requestFrameAnimation?

Dador commented 7 years ago

I was testing JavascriptSubtitlesOctopus with this test subtitle (railgun opening with krk fx) and it crashed. It is a super heavy subtitle that I use to benchmark. I had the same problem when compiling with Web Assembly in libass.js and it can be fixed using -s "BINARYEN_TRAP_MODE='clamp'".

Thank you, I'll try it 😃

I also would like to suggest to use requestFrameAnimation instead setTimeout in JavascriptSubtitlesOctopus.

requestAnimationFrame already used when possible but it can't be used inside of web worker. With introduction of Webassembly I'm not sure if web worker still necessary (but it still can be necessary on mobile).

Yay295 commented 7 years ago

I would be interested in seeing the Railgun subs with different subtitle implementations. We use our own implementation at openings.moe, and that OP can be seen here.

(there's a known positioning issue with Chrome at the start. it works in Firefox.)

Dador commented 7 years ago

I fixed the issue @dead talked about.

Here is example with Railgun: https://dador.github.io/JavascriptSubtitlesOctopus/railgun_op.html (I've used subtitles that @dead sent before).