Skip to content

New Interface for LibASS #64

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

Merged
merged 21 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
22 changes: 22 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Emscripten

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Checkout submodules
shell: bash
run: |
git submodule sync
git submodule update --init --force
- name: Build the Docker image
run: docker build . --file Dockerfile --tag dador/javascriptsubtitlesoctopus:latest
- name: Build All
run: docker run --rm -v ${PWD}:/code dador/javascriptsubtitlesoctopus:latest
- uses: actions/upload-artifact@v1
with:
name: js
path: dist/js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ a.out.wasm
a.out.js.mem
a.out
src/.deps/
src/WebIDLGrammar.pkl
src/parser.out
src/Makefile
src/Makefile.in
src/aclocal.m4
Expand All @@ -21,5 +23,6 @@ dist/libraries/
*.lo
*.la
*.o
*.pyc
venv/
node_modules/
36 changes: 0 additions & 36 deletions .gitlab-ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
[submodule "lib/brotli"]
path = lib/brotli
url = https://github.com/google/brotli
ignore = dirty
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM debian:buster
RUN apt-get update && apt-get install -y \
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 \
clang \
cmake \
Expand All @@ -10,19 +11,25 @@ RUN apt-get update && apt-get install -y \
libtool \
itstool \
pkg-config \
python2 \
python3 \
zip \
python-lxml \
python-pip \
python-html5lib \
python-chardet \
gettext \
autopoint \
automake \
autoconf \
m4 \
gperf && \
git clone https://github.com/emscripten-core/emsdk.git && \
rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/emscripten-core/emsdk.git && \
cd emsdk && \
./emsdk install latest && \
./emsdk activate latest
ENV PATH=$PATH:/emsdk:/emsdk/fastcomp/emscripten:/emsdk/node/12.9.1_64bit/bin
./emsdk install 1.39.11 && \
./emsdk activate 1.39.11

ENV PATH=$PATH:/emsdk:/emsdk/upstream/emscripten:/emsdk/node/12.9.1_64bit/bin
WORKDIR /code
CMD ["make"]
43 changes: 21 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ lib/fribidi/configure:
patch -d "$(BASE_DIR)lib/fribidi" -Np1 -i $(file);) \
NOCONFIGURE=1 ./autogen.sh

# NM=llvm-nm
dist/libraries/lib/libfribidi.a: lib/fribidi/configure
cd lib/fribidi && \
emconfigure ./configure \
Expand All @@ -26,7 +25,7 @@ dist/libraries/lib/libfribidi.a: lib/fribidi/configure
-O2 \
-s NO_FILESYSTEM=1 \
-s NO_EXIT_RUNTIME=1 \
-s STRICT=1 \
-DFRIBIDI_ENTRY=extern \
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
Expand All @@ -40,7 +39,6 @@ dist/libraries/lib/libfribidi.a: lib/fribidi/configure
&& \
emmake make -j8 && \
emmake make install


lib/expat/expat/configured:
cd lib/expat/expat && \
Expand All @@ -51,13 +49,12 @@ lib/expat/expat/configured:

dist/libraries/lib/libexpat.a: lib/expat/expat/configured
cd lib/expat/expat/build && \
emconfigure cmake \
emcmake cmake \
-DCMAKE_C_FLAGS=" \
-s USE_PTHREADS=0 \
-O2 \
-s NO_FILESYSTEM=1 \
-s NO_EXIT_RUNTIME=1 \
-s STRICT=1 \
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
Expand All @@ -82,7 +79,7 @@ lib/brotli/configured:

dist/libraries/lib/libbrotlidec.a: lib/brotli/configured
cd lib/brotli/build && \
emconfigure cmake \
emcmake cmake \
-DCMAKE_C_FLAGS=" \
-O2 \
" \
Expand Down Expand Up @@ -110,7 +107,6 @@ lib/freetype/build_hb/dist_hb/lib/libfreetype.a: dist/libraries/lib/libbrotlidec
-O2 \
-s NO_FILESYSTEM=1 \
-s NO_EXIT_RUNTIME=1 \
-s STRICT=1 \
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
Expand Down Expand Up @@ -146,7 +142,6 @@ dist/libraries/lib/libharfbuzz.a: lib/freetype/build_hb/dist_hb/lib/libfreetype.
-O2 \
-s NO_FILESYSTEM=1 \
-s NO_EXIT_RUNTIME=1 \
-s STRICT=1 \
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
Expand Down Expand Up @@ -182,7 +177,6 @@ dist/libraries/lib/libfreetype.a: dist/libraries/lib/libharfbuzz.a dist/librarie
-O2 \
-s NO_FILESYSTEM=1 \
-s NO_EXIT_RUNTIME=1 \
-s STRICT=1 \
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
Expand Down Expand Up @@ -220,7 +214,6 @@ dist/libraries/lib/libfontconfig.a: dist/libraries/lib/libharfbuzz.a dist/librar
-O2 \
-s NO_EXIT_RUNTIME=1 \
--llvm-lto 1 \
-s STRICT=1 \
-s MODULARIZE=1 \
" \
--prefix="$(DIST_DIR)" \
Expand Down Expand Up @@ -252,7 +245,6 @@ dist/libraries/lib/libass.a: dist/libraries/lib/libfontconfig.a dist/libraries/l
-s USE_PTHREADS=0 \
-O2 \
-s NO_EXIT_RUNTIME=1 \
-s STRICT=1 \
--llvm-lto 1 \
-s MODULARIZE=1 \
" \
Expand Down Expand Up @@ -280,7 +272,12 @@ OCTP_DEPS = \
$(DIST_DIR)/lib/libfontconfig.a \
$(DIST_DIR)/lib/libass.a

src/Makefile:
# Require a patch to fix some errors
src/SubOctpInterface.cpp:
cd src && \
python ../build/webidl_binder.py SubtitleOctopus.idl SubOctpInterface

src/Makefile: src/SubOctpInterface.cpp
cd src && \
autoreconf -fi

Expand All @@ -294,14 +291,13 @@ src/subtitles-octopus-worker.bc: dist/libraries/lib/libass.a src/Makefile
# Dist Files
EMCC_COMMON_ARGS = \
-O2 \
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_libassjs_init', '_libassjs_quit', '_libassjs_resize', '_libassjs_render', '_libassjs_free_track', '_libassjs_create_track']" \
-s EXPORTED_FUNCTIONS="['_main', '_malloc']" \
-s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap', 'getValue', 'FS_createPreloadedFile', 'FS_createFolder']" \
-s NO_EXIT_RUNTIME=1 \
--use-preload-plugins \
--preload-file default.woff2 \
--preload-file fonts.conf \
--preload-file assets/default.woff2 \
--preload-file assets/fonts.conf \
-s ALLOW_MEMORY_GROWTH=1 \
-s STRICT=1 \
-s FORCE_FILESYSTEM=1 \
--llvm-lto 1 \
-g1 \
Expand All @@ -311,34 +307,37 @@ EMCC_COMMON_ARGS = \
#--memory-init-file 0 \
#-s OUTLINING_LIMIT=20000 \

dist: src/subtitles-octopus-worker.bc dist/subtitles-octopus-worker.js dist/subtitles-octopus-worker-legacy.js dist/subtitles-octopus.js
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/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc
dist/js/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc
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/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc
dist/js/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc
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 \
$(EMCC_COMMON_ARGS)

dist/subtitles-octopus.js:
cp src/subtitles-octopus.js dist/
dist/js/subtitles-octopus.js:
cp src/subtitles-octopus.js dist/js/

# Clean Tasks

clean: clean-dist clean-freetype clean-fribidi clean-harfbuzz clean-fontconfig clean-expat clean-libass clean-octopus clean-brotli

clean-dist:
cd dist && rm -frv ./*
cd dist && rm -frv ./libraries/* && rm -frv ./js/*
clean-freetype:
cd lib/freetype && git clean -fdx
clean-fribidi:
Expand Down
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://gitlab.com/TFSThiagoBR98/JavascriptSubtitlesOctopus/badges/master/build.svg)](https://gitlab.com/TFSThiagoBR98/JavascriptSubtitlesOctopus/pipelines)
[![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).

Expand Down Expand Up @@ -137,33 +137,27 @@ To use, just run: `brotli subFile.ass` and use the .br result file with the subU
* ragel
* make
* autoconf
* python2
* python3
* pkgconfig
* patch
* libtool
* itstool
* automake
* python2-lxml
* python2-pip
* python2-html5lib
* python2-chardet
* python-lxml
* python-pip
* python-html5lib
* python-chardet
* gperf

### Get the Source

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

### Build
1) Install Dependencies, see above
2) `cd JavascriptSubtitlesOctopus`
3) `make`
4) Artifacts are in /dist

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

## Why "Octopus"?
How am I an Octopus? [Ba da ba da ba!](https://www.youtube.com/watch?v=tOzOD-82mW0)
File renamed without changes.
0 fonts.conf → assets/fonts.conf
100755 → 100644
File renamed without changes.
Loading