Skip to content

Modernize library, bugfixes, improvements #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 86 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
848a686
Begin implementing render on demand
JustAMan Mar 18, 2020
65fbfec
Change return type of renderBlend()
JustAMan Mar 23, 2020
5430cc9
Reset render cache when target size changes
JustAMan Mar 19, 2020
4e42502
Add lots of debug logging, limit render fps of events
JustAMan Mar 19, 2020
90910bd
Trying to handle seek better
JustAMan Mar 20, 2020
21c84cc
* Start rendering only when video size is determined (e.g. video load…
JustAMan Mar 20, 2020
6980deb
Less zealous logging
JustAMan Mar 20, 2020
6d3a5c7
Rework buffer into C++ class
JustAMan Mar 23, 2020
7fc34cf
Event time findings are now proper members (but not exported yet)
JustAMan Mar 23, 2020
cea2dc9
Expose findEventStopTimes and findNextEventStart properly
JustAMan Mar 23, 2020
88d2df4
Use properly bound APIs
JustAMan Mar 23, 2020
bd8bcab
No longer need to export functions via makefile
JustAMan Mar 23, 2020
ecd47dd
Use correct function to get event times
JustAMan Mar 23, 2020
67947f3
Fix some issues caused by moving to C++ bindings
JustAMan Mar 23, 2020
e0c8cb8
Fix libass build
JustAMan Mar 23, 2020
9dd6eb2
Fix oneshot render
JustAMan Mar 23, 2020
e1604cb
Try to fix animations flickering
JustAMan Mar 23, 2020
b91377e
Merge pull request #6 from JustAMan/improve-timing-accuracy
JustAMan Mar 24, 2020
a8d670e
Reduce blinking of subs when in lite mode
JustAMan Mar 20, 2020
d3bc472
Change SubtitleOctopus class API - added a few methods to be used in …
JustAMan Mar 24, 2020
90d4848
Fix build and warnings
JustAMan Mar 24, 2020
a66e797
Add option to client-facing API to drop all animations, pass it down …
JustAMan Mar 24, 2020
971a997
Make octopus.setDropAnimations(true) mean something
JustAMan Mar 24, 2020
a166606
Try fix holes in rendering
JustAMan Mar 24, 2020
4478d25
Merge pull request #8 from JustAMan/lite-mode
JustAMan Mar 25, 2020
f98bc52
Fix build following @TFSThiagoBR98 suggestion
JustAMan Mar 24, 2020
d38b2b5
Remove generated files
JustAMan Mar 24, 2020
3c864b1
Ignore more build artifacts
JustAMan Mar 25, 2020
bc33fd6
Merge pull request #10 from JustAMan/fix-build
JustAMan Mar 25, 2020
8bc0001
Change binding part of BlendRenderResult
JustAMan Mar 24, 2020
0cc2bf8
Restructure renderBlend so it can return multiple pieces; JS side not…
JustAMan Mar 24, 2020
c08fd1d
Adapt JS side to renderBlend potentially returning a list of images
JustAMan Mar 24, 2020
efabc64
Fix build
JustAMan Mar 24, 2020
707a398
Fix skipping images when rendering a part
JustAMan Mar 24, 2020
efed854
Implement splitting by 3x3 grid
JustAMan Mar 24, 2020
a87c702
Fix issues found in review
JustAMan Mar 25, 2020
1b4c88f
Merge pull request #9 from JustAMan/wind-gusts-ripping-canvas
JustAMan Mar 25, 2020
825c999
Handle resizing more efficiently - if video changed less than 20% kee…
JustAMan Mar 25, 2020
345d701
Add ability to limit canvas size
JustAMan Mar 25, 2020
4c5f018
Bump default max height to 2160
JustAMan Mar 25, 2020
bcf4b5f
Add option to disable scaling altogether when height is less than har…
JustAMan Mar 25, 2020
5256b63
Add option to control how much size may vary until the prerender cach…
JustAMan Mar 25, 2020
42c3b62
Merge pull request #11 from JustAMan/limit-canvas-size
JustAMan Mar 25, 2020
cc9575c
Fix prerender cache not clearing upon track switch
JustAMan Mar 25, 2020
93f4d0f
Handle resize better - leave leftmost items be upon resizing
JustAMan Mar 25, 2020
0722559
Do not reset prerender cache when resize is not actually a resize
JustAMan Mar 25, 2020
3269ee2
Merge pull request #12 from JustAMan/fix-resize
JustAMan Mar 25, 2020
7e6b75d
Committing built files
JustAMan Mar 25, 2020
03e841c
Add patching of emscripten.
JustAMan Apr 4, 2020
a11f25f
commit built files
JustAMan Apr 4, 2020
ddf2959
Address review comments
JustAMan Apr 8, 2020
b380565
Merge pull request #14 from JustAMan/patch-emscripten
JustAMan Apr 8, 2020
82822b2
Use newer emsdk with proper webview support, tune some options
JustAMan Apr 27, 2020
6444522
Remove const usage for older browsers compat
JustAMan Apr 27, 2020
9299074
Add Uin8Array.slice() polyfill
JustAMan Apr 27, 2020
7eefe74
Make resetRenderAheadCache public
JustAMan Apr 27, 2020
595d0e2
Reduce spam in logs when worker is not yet initialized
JustAMan Apr 27, 2020
84bbb59
Add built files to dist
JustAMan Apr 27, 2020
58e9a3f
Merge pull request #15 from JustAMan/update-build
JustAMan Apr 27, 2020
23856d3
Added Noto Sans CJK as default fallback
WeebDataHoarder Sep 6, 2020
2e79d26
Disable fast renderMode when lacking createImageBitmap on worker
WeebDataHoarder Sep 6, 2020
aec38be
Added data URI font loader
WeebDataHoarder Sep 6, 2020
b2f91f4
Added new dist files
WeebDataHoarder Sep 6, 2020
5304703
Updated README to point towards right repository URL
WeebDataHoarder Apr 9, 2021
611ebdc
Updated fribidi to 1.0.10 + patches on master
WeebDataHoarder Apr 9, 2021
8497964
Updated libass to 0.15.0
WeebDataHoarder Apr 9, 2021
65d6665
Updated fontconfig to 2.13.93
WeebDataHoarder Apr 9, 2021
c0c5e16
Updated freetype to 2.10.4
WeebDataHoarder Apr 9, 2021
fa4c1da
Updated expat to 2.3.0
WeebDataHoarder Apr 9, 2021
33f8a9b
Updated brotli to 1.0.9
WeebDataHoarder Apr 9, 2021
9c40a26
Changed name on github workflow
WeebDataHoarder Apr 9, 2021
e7d1ae4
Add ready event upon worker-init
WeebDataHoarder Apr 9, 2021
823880b
downgrade harfbuzz, update Dockerfile, change minimum supported versi…
WeebDataHoarder Apr 9, 2021
42776f9
fix export/module loading
WeebDataHoarder Apr 9, 2021
dbcad8d
added decoding of embedded fonts
WeebDataHoarder Apr 9, 2021
553dead
fix libass dropping lines
WeebDataHoarder Apr 9, 2021
75a07fc
Fixed fontconfig cachedir
WeebDataHoarder Apr 22, 2021
c3751f5
Removed brotli subtitle support (just send them compressed on network!)
WeebDataHoarder Apr 22, 2021
4abfd94
Bumped emsdk to 2.0.2, fixed errors of compilation
WeebDataHoarder Apr 23, 2021
1e57d1d
Added dynamic loading of fallback/default font
WeebDataHoarder Apr 23, 2021
2c26faf
Create unified single interface with WASM=2 (remove -legacy worker), …
WeebDataHoarder Apr 23, 2021
d678367
Enable large-tiles by default
WeebDataHoarder Apr 25, 2021
04247b6
modernise library
ThaUnknown Jul 21, 2021
da86f2b
revert datahoarder's changes
ThaUnknown Jul 21, 2021
2a112e4
change events [bit spammy, but works a lot better on very heavy video…
ThaUnknown Jul 26, 2021
09838f7
remove dist, cleanup
ThaUnknown Aug 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
*/*/.git
.gitmodules
.gitignore
dist/
4 changes: 2 additions & 2 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
git submodule sync
git submodule update --init --force
- name: Build the Docker image
run: docker build . --file Dockerfile --tag dador/javascriptsubtitlesoctopus:latest
run: docker build . --file Dockerfile --tag libass/javascriptsubtitlesoctopus:latest
- name: Build All
run: docker run --rm -v ${PWD}:/code dador/javascriptsubtitlesoctopus:latest
run: docker run --rm -v ${PWD}/dist/js:/code/dist/js libass/javascriptsubtitlesoctopus:latest
- uses: actions/upload-artifact@v1
with:
name: js
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ dist/libraries/
*.pyc
venv/
node_modules/
.idea/
src/SubOctpInterface.cpp
src/SubOctpInterface.js
26 changes: 21 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM debian:buster

RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/force-unsafe-io
RUN apt-get update && apt-get install -y --no-install-recommends \
llvm \
Expand All @@ -22,15 +23,30 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
automake \
autoconf \
m4 \
gperf && \
pip install ply && \
gperf \
wget && \
rm -rf /var/lib/apt/lists/*

RUN pip install ply


ARG EMSCRIPTEN_TAG=2.0.2

RUN git clone https://github.com/emscripten-core/emsdk.git && \
cd emsdk && \
./emsdk install 1.39.11 && \
./emsdk activate 1.39.11
./emsdk install ${EMSCRIPTEN_TAG} && \
./emsdk activate ${EMSCRIPTEN_TAG}

ENV PATH=$PATH:/emsdk:/emsdk/upstream/emscripten:/emsdk/node/12.9.1_64bit/bin
ENV PATH=$PATH:/emsdk:/emsdk/upstream/emscripten:/emsdk/node/14.15.5_64bit/bin
WORKDIR /code

COPY . /code

#Fixes fribidi requiring a git repository as a submodule
RUN cd lib/fribidi/ && git init && git -c user.email="bogus@example.com" -c user.name="bogus" commit --allow-empty -m "bogus" && cd /code
#Fixes fontconfig requiring a git repository as a submodule
RUN cd lib/fontconfig/ && git init && git -c user.email="bogus@example.com" -c user.name="bogus" commit --allow-empty -m "bogus" && cd /code
#Fixes libass requiring a git repository as a submodule
RUN cd lib/libass/ && git init && git -c user.email="bogus@example.com" -c user.name="bogus" commit --allow-empty -m "bogus" && cd /code

CMD ["make"]
108 changes: 69 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
BASE_DIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
DIST_DIR:=$(BASE_DIR)dist/libraries

GLOBAL_CFLAGS:=-O3
GLOBAL_CFLAGS:=-O3 -g0 -s ENVIRONMENT=web,worker -s DOUBLE_MODE=0
GLOBAL_LDFLAGS:=

all: subtitleoctopus

Expand All @@ -19,9 +20,12 @@ lib/fribidi/configure:
patch -d "$(BASE_DIR)lib/fribidi" -Np1 -i $(file);) \
NOCONFIGURE=1 ./autogen.sh

dist/libraries/lib/libfribidi.a: lib/fribidi/configure
$(DIST_DIR)/lib/libfribidi.a: lib/fribidi/configure
cd lib/fribidi && \
emconfigure ./configure \
LDFLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
CFLAGS=" \
-s USE_PTHREADS=0 \
$(GLOBAL_CFLAGS) \
Expand Down Expand Up @@ -49,9 +53,12 @@ lib/expat/expat/configured:
patch -d "$(BASE_DIR)lib/expat" -Np1 -i $(file);) \
touch configured && mkdir build

dist/libraries/lib/libexpat.a: lib/expat/expat/configured
$(DIST_DIR)/lib/libexpat.a: lib/expat/expat/configured
cd lib/expat/expat/build && \
emcmake cmake \
-DCMAKE_STATIC_LINKER_FLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
-DCMAKE_C_FLAGS=" \
-s USE_PTHREADS=0 \
$(GLOBAL_CFLAGS) \
Expand Down Expand Up @@ -79,31 +86,44 @@ lib/brotli/configured:
patch -d "$(BASE_DIR)lib/brotli" -Np1 -i $(file);) \
touch configured && mkdir build

dist/libraries/lib/libbrotlidec.a: lib/brotli/configured
lib/brotli/build/libbrotlidec.pc: lib/brotli/configured
cd lib/brotli/build && \
emcmake cmake \
-DCMAKE_STATIC_LINKER_FLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
-DCMAKE_C_FLAGS=" \
$(GLOBAL_CFLAGS) \
" \
-DCMAKE_INSTALL_PREFIX=$(DIST_DIR) \
.. \
&& \
emmake make -j8 && \
mkdir -p ../../../dist/libraries/lib/pkgconfig && \
mv libbrotlidec.pc ../../../dist/libraries/lib/pkgconfig && \
mv libbrotlicommon.pc ../../../dist/libraries/lib/pkgconfig && \
mv libbrotlidec-static.a ../../../dist/libraries/lib/libbrotlidec.a && \
mv libbrotlicommon-static.a ../../../dist/libraries/lib/libbrotlicommon.a && \
cp -r ../c/include ../../../dist/libraries/
cp -r ../c/include $(DIST_DIR)

$(DIST_DIR)/lib/libbrotlicommon.a: lib/brotli/build/libbrotlidec.pc
cd lib/brotli/build && \
mkdir -p $(DIST_DIR)/lib/pkgconfig && \
cp libbrotlicommon.pc $(DIST_DIR)/lib/pkgconfig && \
cp libbrotlicommon-static.a $(DIST_DIR)/lib/libbrotlicommon.a

$(DIST_DIR)/lib/libbrotlidec.a: lib/brotli/build/libbrotlidec.pc $(DIST_DIR)/lib/libbrotlicommon.a
cd lib/brotli/build && \
mkdir -p $(DIST_DIR)/lib/pkgconfig && \
cp libbrotlidec.pc $(DIST_DIR)/lib/pkgconfig && \
cp libbrotlidec-static.a $(DIST_DIR)/lib/libbrotlidec.a

# Freetype without Harfbuzz
lib/freetype/build_hb/dist_hb/lib/libfreetype.a: dist/libraries/lib/libbrotlidec.a
lib/freetype/build_hb/dist_hb/lib/libfreetype.a: $(DIST_DIR)/lib/libbrotlidec.a
cd "lib/freetype" && \
NOCONFIGURE=1 ./autogen.sh && \
mkdir -p build_hb && \
cd build_hb && \
EM_PKG_CONFIG_PATH=$(DIST_DIR)/lib/pkgconfig \
emconfigure ../configure \
LDFLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
CFLAGS=" \
-s USE_PTHREADS=0 \
$(GLOBAL_CFLAGS) \
Expand Down Expand Up @@ -135,10 +155,13 @@ lib/harfbuzz/configure:
patch -d "$(BASE_DIR)lib/harfbuzz" -Np1 -i $(file);) \
NOCONFIGURE=1 ./autogen.sh

dist/libraries/lib/libharfbuzz.a: lib/freetype/build_hb/dist_hb/lib/libfreetype.a lib/harfbuzz/configure
$(DIST_DIR)/lib/libharfbuzz.a: lib/freetype/build_hb/dist_hb/lib/libfreetype.a lib/harfbuzz/configure
cd lib/harfbuzz && \
EM_PKG_CONFIG_PATH=$(DIST_DIR)/lib/pkgconfig:$(BASE_DIR)lib/freetype/build_hb/dist_hb/lib/pkgconfig \
emconfigure ./configure \
LDFLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
CFLAGS=" \
-s USE_PTHREADS=0 \
$(GLOBAL_CFLAGS) \
Expand All @@ -147,7 +170,6 @@ dist/libraries/lib/libharfbuzz.a: lib/freetype/build_hb/dist_hb/lib/libfreetype.
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
LDFLAGS="" \
--prefix="$(DIST_DIR)" \
--host=x86-none-linux \
--build=x86_64 \
Expand All @@ -165,7 +187,7 @@ dist/libraries/lib/libharfbuzz.a: lib/freetype/build_hb/dist_hb/lib/libfreetype.
emmake make install

# Freetype with Harfbuzz
dist/libraries/lib/libfreetype.a: dist/libraries/lib/libharfbuzz.a dist/libraries/lib/libbrotlidec.a
$(DIST_DIR)/lib/libfreetype.a: $(DIST_DIR)/lib/libharfbuzz.a $(DIST_DIR)/lib/libbrotlidec.a
cd "lib/freetype" && \
git reset --hard && \
$(foreach file, \
Expand All @@ -174,6 +196,9 @@ dist/libraries/lib/libfreetype.a: dist/libraries/lib/libharfbuzz.a dist/librarie
NOCONFIGURE=1 ./autogen.sh && \
EM_PKG_CONFIG_PATH=$(DIST_DIR)/lib/pkgconfig \
emconfigure ./configure \
LDFLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
CFLAGS=" \
-s USE_PTHREADS=0 \
$(GLOBAL_CFLAGS) \
Expand All @@ -198,18 +223,21 @@ dist/libraries/lib/libfreetype.a: dist/libraries/lib/libharfbuzz.a dist/librarie
emmake make install

# Fontconfig
lib/fontconfig/configure:
lib/fontconfig/configure:
cd lib/fontconfig && \
git reset --hard && \
$(foreach file, \
$(wildcard $(BASE_DIR)build/patches/fontconfig/*.patch), \
patch -d "$(BASE_DIR)lib/fontconfig" -Np1 -i $(file);) \
NOCONFIGURE=1 ./autogen.sh

dist/libraries/lib/libfontconfig.a: dist/libraries/lib/libharfbuzz.a dist/libraries/lib/libexpat.a dist/libraries/lib/libfribidi.a dist/libraries/lib/libfreetype.a lib/fontconfig/configure
$(DIST_DIR)/lib/libfontconfig.a: $(DIST_DIR)/lib/libharfbuzz.a $(DIST_DIR)/lib/libexpat.a $(DIST_DIR)/lib/libfribidi.a $(DIST_DIR)/lib/libfreetype.a lib/fontconfig/configure
cd lib/fontconfig && \
EM_PKG_CONFIG_PATH=$(DIST_DIR)/lib/pkgconfig \
emconfigure ./configure \
LDFLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
CFLAGS=" \
-s USE_PTHREADS=0 \
-DEMSCRIPTEN \
Expand Down Expand Up @@ -239,10 +267,13 @@ lib/libass/configure:
patch -d "$(BASE_DIR)lib/libass" -Np1 -i $(file);) \
NOCONFIGURE=1 ./autogen.sh

dist/libraries/lib/libass.a: dist/libraries/lib/libfontconfig.a dist/libraries/lib/libharfbuzz.a dist/libraries/lib/libexpat.a dist/libraries/lib/libfribidi.a dist/libraries/lib/libfreetype.a dist/libraries/lib/libbrotlidec.a lib/libass/configure
$(DIST_DIR)/lib/libass.a: $(DIST_DIR)/lib/libfontconfig.a $(DIST_DIR)/lib/libharfbuzz.a $(DIST_DIR)/lib/libexpat.a $(DIST_DIR)/lib/libfribidi.a $(DIST_DIR)/lib/libfreetype.a $(DIST_DIR)/lib/libbrotlidec.a lib/libass/configure
cd lib/libass && \
EM_PKG_CONFIG_PATH=$(DIST_DIR)/lib/pkgconfig \
emconfigure ./configure \
LDFLAGS=" \
$(GLOBAL_LDFLAGS) \
" \
CFLAGS=" \
-s USE_PTHREADS=0 \
$(GLOBAL_CFLAGS) \
Expand All @@ -256,6 +287,7 @@ dist/libraries/lib/libass.a: dist/libraries/lib/libfontconfig.a dist/libraries/l
--disable-shared \
--enable-static \
--disable-asm \
--enable-large-tiles \
\
--enable-harfbuzz \
--enable-fontconfig \
Expand Down Expand Up @@ -283,7 +315,7 @@ src/Makefile: src/SubOctpInterface.cpp
cd src && \
autoreconf -fi && \
EM_PKG_CONFIG_PATH=$(DIST_DIR)/lib/pkgconfig \
emconfigure ./configure --host=x86-none-linux --build=x86_64 CFLAGS="$(GLOBAL_CFLAGS)"
emconfigure ./configure --host=x86-none-linux --build=x86_64 LDFLAGS="$(GLOBAL_LDFLAGS)" CFLAGS="$(GLOBAL_CFLAGS)"

src/subtitles-octopus-worker.bc: $(OCTP_DEPS) src/Makefile src/SubtitleOctopus.cpp src/SubOctpInterface.cpp
cd src && \
Expand All @@ -294,40 +326,38 @@ src/subtitles-octopus-worker.bc: $(OCTP_DEPS) src/Makefile src/SubtitleOctopus.c
EMCC_COMMON_ARGS = \
$(GLOBAL_CFLAGS) \
-s EXPORTED_FUNCTIONS="['_main', '_malloc']" \
-s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap', 'getValue', 'FS_createPreloadedFile', 'FS_createFolder']" \
-s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap', 'getValue', 'FS_createPreloadedFile', 'FS_createFolder', 'FS_createLazyFile']" \
-s NO_EXIT_RUNTIME=1 \
--use-preload-plugins \
--preload-file assets/default.woff2 \
--preload-file assets/fonts.conf \
-s MALLOC=emmalloc \
-s ALLOW_MEMORY_GROWTH=1 \
-s INITIAL_MEMORY=67108864 \
--embed-file assets/fonts.conf \
-s FORCE_FILESYSTEM=1 \
-s ENVIRONMENT=web,worker \
-s DOUBLE_MODE=0 \
-s EVAL_CTORS=1 \
-s TEXTDECODER=2 \
-s LEGACY_VM_SUPPORT=0 \
-s MIN_CHROME_VERSION=75 \
-s MIN_FIREFOX_VERSION=65 \
-s MIN_EDGE_VERSION=0x7FFFFFFF \
-s MIN_SAFARI_VERSION=120000 \
--llvm-lto 1 \
--no-heap-copy \
--memory-init-file 0 \
-flto \
-o $@
#--js-opts 0 -g4 \
#--closure 1 \
#--memory-init-file 0 \
#-s WASM_BIGINT \
#-s OUTLINING_LIMIT=20000 \

dist: src/subtitles-octopus-worker.bc dist/js/subtitles-octopus-worker.js dist/js/subtitles-octopus-worker-legacy.js dist/js/subtitles-octopus.js

dist/js/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc src/pre-worker.js src/unbrotli.js src/SubOctpInterface.js src/post-worker.js
emcc src/subtitles-octopus-worker.bc $(OCTP_DEPS) \
--pre-js src/pre-worker.js \
--pre-js src/unbrotli.js \
--post-js src/SubOctpInterface.js \
--post-js src/post-worker.js \
-s WASM=1 \
$(EMCC_COMMON_ARGS)
dist: src/subtitles-octopus-worker.bc dist/js/subtitles-octopus-worker.js dist/js/subtitles-octopus.js

dist/js/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc src/pre-worker.js src/unbrotli.js src/SubOctpInterface.js src/post-worker.js
dist/js/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc src/pre-worker.js src/SubOctpInterface.js src/post-worker.js
emcc src/subtitles-octopus-worker.bc $(OCTP_DEPS) \
--pre-js src/pre-worker.js \
--pre-js src/unbrotli.js \
--post-js src/SubOctpInterface.js \
--post-js src/post-worker.js \
-s WASM=0 \
-s LEGACY_VM_SUPPORT=1 \
-s WASM=2 \
$(EMCC_COMMON_ARGS)

dist/js/subtitles-octopus.js: src/subtitles-octopus.js
Expand Down
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[![Actions Status](https://github.com/Dador/JavascriptSubtitlesOctopus/workflows/Emscripten/badge.svg)](https://github.com/Dador/JavascriptSubtitlesOctopus/actions)

SubtitlesOctopus displays subtitles in .ass format and easily integrates with HTML5 videos. It supports all SSA/ASS features and fully compatible with [libass](https://github.com/libass/libass).

[ONLINE DEMO](https://dador.github.io/JavascriptSubtitlesOctopus/videojs.html) / [other examples with demo](https://dador.github.io/JavascriptSubtitlesOctopus/)

## Features

- Supports all SSA/ASS features
Expand Down Expand Up @@ -31,17 +27,17 @@ To start using SubtitlesOctopus you only need to instantiate a new instance of
var options = {
video: document.getElementById('video'), // HTML5 video element
subUrl: '/test/test.ass', // Link to subtitles
fallbackFont: '/test/font-1.ttf', // Fallback font to be used in case none can be loaded / or has special characters
fonts: ['/test/font-1.ttf', '/test/font-2.ttf'], // Links to fonts (not required, default font already included in build)
workerUrl: '/libassjs-worker.js', // Link to WebAssembly-based file "libassjs-worker.js"
legacyWorkerUrl: '/libassjs-worker-legacy.js' // Link to non-WebAssembly worker
workerUrl: '/subtitles-octopus-worker.js', // Link to worker file "libassjs-worker.js"
};
var instance = new SubtitlesOctopus(options);
```

After that SubtitlesOctopus automatically "connects" to your video and it starts
to display subtitles. You can use it with any HTML5 player.

[See other examples](https://github.com/Dador/JavascriptSubtitlesOctopus/tree/master/example).
[See other examples](https://github.com/libass/JavascriptSubtitlesOctopus/tree/master/example).

### Using only with canvas
You're also able to use it without any video. However, that requires you to set
Expand All @@ -51,8 +47,9 @@ the time the subtitles should render at yourself:
var options = {
canvas: document.getElementById('canvas'), // canvas element
subUrl: '/test/test.ass', // Link to subtitles
fonts: ['/test/font-1.ttf', '/test/font-2.ttf'], // Links to fonts (not required, default font already included in build)
workerUrl: '/libassjs-worker.js' // Link to file "libassjs-worker.js"
fallbackFont: '/test/font-1.ttf', // Fallback font to be used in case none can be loaded / or has special characters
fonts: ['/test/font-1.ttf', '/test/font-2.ttf'], // Links to fonts
workerUrl: '/subtitles-octopus-worker.js' // Link to file "libassjs-worker.js"
};
var instance = new SubtitlesOctopus(options);
// And then...
Expand Down Expand Up @@ -102,7 +99,8 @@ When creating an instance of SubtitleOctopus, you can set the following options:
`subContent` to be specified)
- `subContent`: The content of the subtitle file to play. (Require either
`subContent` or `subUrl` to be specified)
- `workerUrl`: The URL of the worker. (Default: `libassjs-worker.js`)
- `workerUrl`: The URL of the worker. (Default: `subtitles-octopus-worker.js`)
- `fallbackFont`: The URL of a fallback font to be used in case none can be loaded / or has special characters
- `fonts`: An array of links to the fonts used in the subtitle. (Optional)
- `availableFonts`: Object with all available fonts - Key is font name in lower
case, value is link: `{"arial": "/font1.ttf"}` (Optional)
Expand All @@ -122,11 +120,6 @@ The Fast Render mode has been created by @no1d as a suggestion for fix browser f

To enable this mode set the option `lossyRender` to `true` when creating an instance of SubtitleOctopus.

### Brotli Compressed Subtitles
The SubtitleOctopus allow the use of compressed subtitles in brotli format, saving bandwidth and reducing library startup time

To use, just run: `brotli subFile.ass` and use the .br result file with the subUrl option

## How to build?

### Dependencies
Expand All @@ -151,12 +144,12 @@ To use, just run: `brotli subFile.ass` and use the .br result file with the subU

### Get the Source

Run `git clone --recursive https://github.com/Dador/JavascriptSubtitlesOctopus.git`
Run `git clone --recursive https://github.com/libass/JavascriptSubtitlesOctopus.git`

### Build with Docker
1) Install Docker
2) `docker build -t dador/javascriptsubtitlesoctopus .`
3) `docker run -it --rm -v ${PWD}:/code dador/javascriptsubtitlesoctopus:latest`
2) `docker build -t libass/javascriptsubtitlesoctopus .`
3) `docker run -it --rm -v ${PWD}/dist/js:/code/dist/js libas/javascriptsubtitlesoctopus:latest`
4) Artifacts are in /dist/js

## Why "Octopus"?
Expand Down
Binary file removed assets/default.woff2
Binary file not shown.
Loading