Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
[![ass-kt - Version](https://img.shields.io/maven-central/v/io.github.peerless2012/ass-kt?label=ass-kt)](https://central.sonatype.com/artifact/io.github.peerless2012/ass-kt)
[![ass-media - Version](https://img.shields.io/maven-central/v/io.github.peerless2012/ass-media?label=ass-media)](https://central.sonatype.com/artifact/io.github.peerless2012/ass-media)

A collection of libraries for implementing [libass](https://github.com/libass/libass) for Android.
A collection of libraries for implementing [libass](https://github.com/libass/libass) into Android apps.

It use [libass-cmake](https://github.com/peerless2012/libass-cmake) to build libass.
It is built using [libass-cmake](https://github.com/peerless2012/libass-cmake).

## Modules
### [lib_ass](./lib_ass)
A native build library with prefab feature, this module contains libass.so and the header files.
A native build library with prefab features, this module contains libass.so and its header files.

App want to use libass in C/C++ can use this module.
Apps that want to use libass in C/C++ can use this module.

### [lib_ass_kt](./lib_ass_kt)
A kotlin wrapper for libass native api.
A kotlin wrapper for libass's native api.

App want to use libass in java/kotlin can use this module.
Apps that want to use libass with java/kotlin can use this module.

### [lib_ass_media](./lib_ass_media)
A media3 extend library for libass.
A media3 extension library for libass.

App use media3 can use this module to add ass for your player.
Apps that use media3 can use this module to implement libass into your player.

## Who is using
| Icon | Name |
Expand All @@ -33,7 +33,7 @@ App use media3 can use this module to add ass for your player.
| <img src="https://avatars.githubusercontent.com/u/267417830" alt="NuvioTV" width="50"> | [NuvioTV](https://github.com/NuvioMedia/NuvioTV) |

## Issue
If you have issue when use, [create](https://github.com/peerless2012/libass-android/issues/new) an issue.
If you have any issues while useing this, [create](https://github.com/peerless2012/libass-android/issues/new) an issue.

## PR
If you want to fix or add feature, [create](https://github.com/peerless2012/libass-android/compare) a pr.
If you want to fix something or add features, [create](https://github.com/peerless2012/libass-android/compare) a pr.
12 changes: 6 additions & 6 deletions lib_ass/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# ASS
A native build library with prefab feature, this module contains libass.so and the header files.
A native build library with prefab features, this module contains libass.so and its header files.

App want to use libass in C/C++ can use this module.
Apps that want to use libass in C/C++ can use this module.

## How to use
1. Add MavenCenter to your project
1. Add MavenCentral to your project
```
allprojects {
repositories {
mavenCentral()
}
}
```
2. Enable prefab feature.
2. Enable the prefab feature.
```
android {
buildFeatures {
Expand All @@ -24,13 +24,13 @@ App want to use libass in C/C++ can use this module.
```
implementation "io.github.peerless2012:ass:x.x.x"
```
4. Add prebuild in `CMakeLists.txt`
4. Add the prebuild in `CMakeLists.txt`
```
# Add these two lines.
find_package(lib_ass REQUIRED CONFIG)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE lib_ass::ass)
```
5. Add libass header in your c/c++ code
5. Add the libass headers in your c/c++ code
```
#include "ass.h"
```
10 changes: 5 additions & 5 deletions lib_ass_kt/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# ASS Kt
A kotlin wrapper for libass native api.
A kotlin wrapper for libass's native api.

App want to use libass in java/kotlin can use this module.
Apps that want to use libass in java/kotlin can use this module.

## How to use
1. Add MavenCenter to your project
1. Add MavenCentral to your project
```
allprojects {
repositories {
mavenCentral()
}
}
```
2. Add dependency.
2. Add the dependency.
```
implementation "io.github.peerless2012:ass-kt:x.x.x"
```
3. Use libass-kt in java/kotlin
3. Use libass-kt your java/kotlin code
```
val ass = ASS()
```
47 changes: 23 additions & 24 deletions lib_ass_media/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# ASS Media
A media3 extend library for libass.
A media3 extension library for libass.

App use media3 can use this module to add ass for your player.
Apps that use media3 can use this module to add libass into their player.

## Feature
There are three ways to render ass subtitle.
Which is defined in `AssRenderType`.
There are three ways to render ass subtitles which are defined in `AssRenderType`.

| Type | Feature | Anim | HDR/DV | Block render/UI |
| :----: | :----: | :----: | :----: | :----: |
Expand All @@ -16,64 +15,64 @@ Which is defined in `AssRenderType`.
| OVERLAY_OPEN_GL | Overlay | ✅ | ✅ | ❌ |

* [OverlayShaderProgram does not support HDR colors yet](https://github.com/androidx/media/issues/723)
* [Why does TextOverLay support hdr, but Bitmap not support?](https://github.com/androidx/media/issues/2383)
* [Why does TextOverLay support hdr, but not Bitmap support?](https://github.com/androidx/media/issues/2383)

### 1. CUES
The ass/ssa subtitle will be parsed and transcode to bytes, and decode to bitmap when render.
The ass/ssa subtitles will be parsed and transcoded into bytes, and decoded into a bitmap when rendered.

This type not support dynamic feature, because all subtitle and it time is static.
This type does not support the dynamic feature, because all subtitles and their time are static.

But since the subtitle is transcode, it will not cost too much time when render. All work is done in parse thread.
However, since the subtitles are transcodeed, they will be to expensiveto render. All the work is done in the parse thread.

### 2. EFFECTS_CANVAS
The ass/ssa subtitle will be cal and render at runtime use media3 effect feature, and this will support all dynamic features.
The ass/ssa subtitles will be calculated and rendered at runtime using the media3 effect feature, this supports all dynamic features.

And this need to create a screen size offscreen bitmap to render the libass bitmap pieces.
This needs the screen size to create an off-screen bitmap and render the libass bitmap pieces.

But when the dynamic feature is too complex, and libass will cost too much time to cal, the render will be blocked.
If a dynamic feature is too complex, libass will take too long to long to calculate and the render will be blocked.

### 3. EFFECTS_OPEN_GL
Just like `EFFECTS_CANVAS`, but use OpenGL to render. and the offscreen tex is create to render the bitmap pieces.
Just like `EFFECTS_CANVAS`, but uses OpenGL to render. and the offscreen text is created to render the bitmap pieces.

Due to test, the `EFFECTS_OPEN_GL` will save 1/3 time when render.
According to tests, the `EFFECTS_OPEN_GL` will take a 1/3 of the time to render.

### 4. OVERLAY_CANVAS
The ass/ssa subtitle will be cal at runtime, and add a `Overlay` widget in `SubtitleView` to render subtitle.
The ass/ssa subtitles will be calculated at runtime, and an `Overlay` widget is added in `SubtitleView` to render the subtitles.

The `libass` render result will copy to bitmap, and draw in `Canvas`.
The `libass` render result will copy into a bitmap, and draw in the `Canvas`.

It will block UI thread when rendering.
This will block UI thread when rendering.

### 4. OVERLAY_OPEN_GL
Just like `OVERLAY_CANVAS`, but the `libass` render result will pass to `OpenGL` texture, and avoid create tmp bitmap.
Just like `OVERLAY_CANVAS`, but the `libass` render result will passed to `OpenGL` as a texture to avoid creating temporary bitmap.

It will save half memory than `OVERLAY_CANVAS`.
It uses about half as much memory as `OVERLAY_CANVAS`.

And the `libass` render and `OpenGL` draw on another separate thread, it will not block the UI thread like `OVERLAY_CANVAS`.
The `libass` renderer and `OpenGL` draw on separate thread, so it will not block the UI thread like `OVERLAY_CANVAS`.


## How to use
1. Add MavenCenter to your project
1. Add MavenCentral to your project
```
allprojects {
repositories {
mavenCentral()
}
}
```
2. Add dependency.
2. Add the dependency.
```
implementation "io.github.peerless2012:ass-media:x.x.x"
```
3. Use libass-media in java/kotlin
3. Using libass-media in your java/kotlin code
```
player = ExoPlayer.Builder(this)
.buildWithAssSupport(
this,
AssRenderType.OPEN_GL
)
```
4. Add external subtitles.
4. Adding external subtitles
```
val enConfig = MediaItem.SubtitleConfiguration
.Builder(Uri.parse("http://192.168.0.254:80/files/f-en.ass"))
Expand Down Expand Up @@ -101,7 +100,7 @@ And the `libass` render and `OpenGL` draw on another separate thread, it will no
.setUri(url)
.setSubtitleConfigurations(ImmutableList.of(enConfig, jpConfig, zhConfig))
```
NOTE: Make sure the `id` is set and different from media self track size. Recommend bigger than 128 or more bigger.
NOTE: Make sure the `id` is set and different from the media self track size. The recommend value is 128 or larger.

## Configuration

Expand Down