Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
name: Build APK (Qualcomm DSP)
runs-on: ubuntu-latest
env:
ANDROID_APK_VERSION: 1.6.10
ANDROID_APK_VERSION: 1.7.0

steps:
- name: checkout code
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
name: Build APK (non-Qualcomm)
runs-on: ubuntu-latest
env:
ANDROID_APK_VERSION: 1.6.10
ANDROID_APK_VERSION: 1.7.0
SKIP_HEXAGON_SDK: "1"
SKIP_OPENCL_SDK: "1"

Expand Down
27 changes: 13 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,17 @@ libggmldsp-skel*.so
CMakeLists.txt

prebuilts/
core/ggml/llamacpp/ggml/src/ggml-opencl/
core/ggml/llamacpp/ggml/src/ggml-sycl/
core/ggml/llamacpp/ggml/src/ggml-virtgpu/
core/ggml/llamacpp/ggml/src/ggml-webgpu/
core/ggml/llamacpp/ggml/src/ggml-zdnn/
core/ggml/llamacpp/ggml/src/ggml-zendnn/
core/ggml/llamacpp/ggml/src/ggml-vulkan/
core/ggml/llamacpp/ggml/src/ggml-openvino/
core/ggml/llamacpp/ggml/src/ggml-sycl/
core/ggml/llamacpp/ggml/src/ggml-rpc/
core/ggml/llamacpp.bak.20260724150435/
core/ggml/llamacpp/ggml/src/ggml-hexagon/htp/ggml_dsp.h
core/ggml/llamacpp/ggml/src/ggml-hexagon/htp/ggml_dsp_skel.c
core/ggml/llamacpp/ggml/src/ggml-hexagon/htp/ggml_dsp_stub.c
core/llamacpp/ggml/src/ggml-opencl/
core/llamacpp/ggml/src/ggml-sycl/
core/llamacpp/ggml/src/ggml-virtgpu/
core/llamacpp/ggml/src/ggml-webgpu/
core/llamacpp/ggml/src/ggml-zdnn/
core/llamacpp/ggml/src/ggml-zendnn/
core/llamacpp/ggml/src/ggml-vulkan/
core/llamacpp/ggml/src/ggml-openvino/
core/llamacpp/ggml/src/ggml-sycl/
core/llamacpp/ggml/src/ggml-rpc/
ggml_dsp.h
ggml_dsp_skel.c
ggml_dsp_stub.c
log*.txt
120 changes: 37 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
# KanTV

KanTV("Kan", aka English "watch") , an open source project focus on study and practise on-device AI technology in <b>real scenario</b>(such as perform <b>online-TV playback</b> and <b>realtime transcription</b> and <b>online-TV record</b> at the same time) on Android phone:
KanTV ("Kan", meaning "watch" in English and "看" in Chinese), an open source project focusing on studying and practicing on-device AI technology in <b>real scenarios</b> (such as performing <b>online-TV playback</b>, <b>realtime transcription</b>, and <b>online-TV recording</b> at the same time) on Android phones:


- Watch online TV and local media by customized ![FFmpeg 6.1](https://github.com/zhouwg/FFmpeg). this project is derived from original ![ijkplayer](https://github.com/zhouwg/kantv/tree/kantv-initial)(that project has stopped maintenance since 2021), with much enhancements and new features. source code of customized FFmpeg 6.1 could be found in <a href="https://github.com/zhouwg/kantv/tree/master/external/ffmpeg-6.1"> external/ffmpeg </a>according to <a href="https://ffmpeg.org/legal.html">FFmpeg's license</a>. source code of FFmpeg 6.1's all dependent libraries could be found in <a href="https://github.com/zhouwg/kantv/tree/master/external/ffmpeg-deps"> external/ffmpeg-deps </a>.
- Watch online TV and local media using a customized ![FFmpeg 6.1](https://github.com/zhouwg/FFmpeg). This project is derived from the original ![ijkplayer](https://github.com/zhouwg/kantv/tree/kantv-initial) (that project has stopped maintenance since 2021), with many enhancements and new features. Source code of the customized FFmpeg 6.1 can be found in <a href="https://github.com/zhouwg/kantv/tree/master/external/ffmpeg-6.1"> external/ffmpeg </a> according to <a href="https://ffmpeg.org/legal.html">FFmpeg's license</a>. Source code of all FFmpeg 6.1's dependent libraries can be found in <a href="https://github.com/zhouwg/kantv/tree/master/external/ffmpeg-deps"> external/ffmpeg-deps </a>.

- Watch online TV by customized ![Google Exoplayer 2.15.1](https://github.com/google/ExoPlayer), source code of customized Exoplayer2.15.1 could be found in <a href="https://github.com/zhouwg/kantv/tree/master/android/kantvplayer-exo2"> android/kantvplayer-exo2 </a>.
- Watch online TV using a customized ![Google ExoPlayer 2.15.1](https://github.com/google/ExoPlayer). Source code of the customized ExoPlayer 2.15.1 can be found in <a href="https://github.com/zhouwg/kantv/tree/master/android/kantvplayer-exo2"> android/kantvplayer-exo2 </a>.

- Record online TV to local file on phone.
- Record online TV to a local file on the phone.

- 2D graphic performance benchmark.

- AI subtitle(real-time English subtitle for English online-TV(aka OTT TV) via the great & excellent & amazing<a href="https://github.com/ggerganov/whisper.cpp"> whisper.cpp </a>).
- AI subtitle (real-time English subtitle for English online-TV (aka OTT TV) via the great & excellent & amazing <a href="https://github.com/ggerganov/whisper.cpp"> whisper.cpp </a>).

- Well-maintained <b>turn-key / self-contained</b> workbench for AI experts/researchers whom focus on highly-value on-device AI R&D activity on Android. some on-device AI R&D activities (AI algorithm validation and AI model validation and performance benchmark with ASR/LLM/MTMD(multimodal) on Android) could be done via this project easily.
- Well-maintained <b>turn-key / self-contained</b> workbench for AI experts/researchers who focus on high-value on-device AI R&D activities on Android. Some on-device AI R&D activities (AI algorithm validation, AI model validation, and performance benchmark with ASR/LLM/MTMD (multimodal) on Android) can be done via this project easily.

- Well-maintained <b>turn-key / self-contained</b> workbench for AI beginners to learning on-device AI technology on Android.
- Well-maintained <b>turn-key / self-contained</b> workbench for AI beginners to learn on-device AI technology on Android.

- Built-in [Alibaba's Qwen1.5-1.8B](https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF), [Alibaba's Qwen2.5-3B](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct-GGUF), [Alibaba's Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B/tree/main), [Google's Gemma3-4B(multimodal text + image)](https://huggingface.co/ggml-org/gemma-3-4b-it-GGUF/tree/main), [Google's Gemma-4-E2B](https://huggingface.co/unsloth/gemma-4-E2B-it-GGUF), [Huggingface's SmolVLM2-256M(highly-optimized multimodal for realtime-video-recognition)](https://huggingface.co/ggml-org/SmolVLM2-256M-Video-Instruct-GGUF), [Alibaba's Qwen2.5-Omni-3B(multimodal text + audio)](https://huggingface.co/ggml-org/Qwen2.5-Omni-3B-GGUF) supportive and runs entirely <b>offline(no Internet required)</b>. these supported LLM models can be [downloaded in the Android APK directly](./docs/how-to-download-ai-models.md) without manually preparation. APK's users can compare the <b>real experience</b> of these LLM models on the Android phone. developers can add other LLM models manually in source code [KANTVAIModelMgr.java](https://github.com/zhouwg/kantv/blob/master/android/kantvplayer-lib/src/main/java/kantvai/ai/KANTVAIModelMgr.java).
- Built-in AI models are supported and run entirely <b>offline (no Internet required)</b>. These supported AI models can be [downloaded in the Android APK directly](./docs/how-to-download-ai-models.md) without manual preparation. APK users can compare the <b>real experience</b> of these AI models on the Android phone. Developers can add other AI models manually in the source code [KANTVAIModelMgr.java](https://github.com/zhouwg/kantv/blob/master/android/kantvplayer-lib/src/main/java/kantvai/ai/KANTVAIModelMgr.java).

- The [ggml-hexagon](https://github.com/zhouwg/kantv/blob/master/core/ggml/llamacpp/ggml/src/ggml-hexagon/ggml-hexagon-jz.cpp) in this project is probably the first open-source reference implementation of a specified llama.cpp backend for Qualcomm Hexagon NPU on Android phone. The backend type (Hexagon cDSP vs. generic ggml) is decided at build time, and the DSP-side thread count is automatically clamped based on the target SoC (e.g., 6 threads on Snapdragon 8Elite, 4 threads on Snapdragon 8Gen3).
| Model | Type | Capability | Source |
|-------|------|-----------|--------|
| ggml-tiny.en-q8_0 | ASR | speech-to-text | [whisper.cpp](https://github.com/ggerganov/whisper.cpp) |
| [Qwen1.5-1.8B](https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF) | LLM | text-only | Alibaba |
| [Qwen2.5-3B](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct-GGUF) | LLM | text-only | Alibaba |
| [Gemma3-4B](https://huggingface.co/ggml-org/gemma-3-4b-it-GGUF/tree/main) | LLM | text + image (MTMD) (known issue: garbled output) | Google |
| [Gemma-4-E2B](https://huggingface.co/unsloth/gemma-4-E2B-it-GGUF) | LLM | text-only (default) | Google |
| [SmolVLM2-256M](https://huggingface.co/ggml-org/SmolVLM2-256M-Video-Instruct-GGUF) | LLM | text + image (realtime-video-recognition) (known issue: regression after merging upstream code, video inference broken, only video preview works, WIP) | Huggingface |
| [Qwen2.5-Omni-3B](https://huggingface.co/ggml-org/Qwen2.5-Omni-3B-GGUF) | LLM | text + audio (MTMD) | Alibaba |

- The [JZ's ggml-hexagon](https://github.com/zhouwg/ggml-hexagon) used in this project is probably the first open-source reference implementation of a specific llama.cpp backend for Qualcomm Hexagon NPU on Android phones. The backend type (Hexagon cDSP vs. generic ggml) is decided at build time, and the DSP-side thread count is automatically clamped based on the target SoC (e.g., 6 threads on Snapdragon 8Elite, 4 threads on Snapdragon 8Gen3). Its PP (prompt processing) and TG (token generation) performance comprehensively surpasses [Qualcomm's official implementation](https://github.com/ggml-org/llama.cpp/tree/master/ggml/src/ggml-hexagon) on Snapdragon 8Elite (aka 8Gen4); benchmark comparisons can be found [here](https://github.com/zhouwg/ggml-hexagon/blob/self-build-jz/docs/backend/jz-ggml-hexagon/ion-mempool-vs-perbuffer-analysis-20260713.md).

### Software architecture of KanTV Android

![Image](https://github.com/user-attachments/assets/32227392-abdf-4760-be3d-a19d48d478ff)
<img width="803" height="517" alt="kantv-arch" src="https://github.com/user-attachments/assets/59e62514-0c1d-44fb-a4fe-dd8d805e17cb" />


### Building the project

Expand All @@ -32,61 +43,34 @@ KanTV("Kan", aka English "watch") , an open source project focus on study and pr
- Download pre-built Android APK from Github CI-build: https://github.com/zhouwg/kantv/actions/

### Run Android APK on Android phone
- Android 8.0(2017.08) --- Android 15(2024.10) and higher version with <b>ANY</b> mainstream arm64 mobile SoC.
- Android smartphone equipped with <b>ANY</b> mainstream <b>high-end</b> mobile SoC is highly <b>recommented</b> for realtime AI-subtitle feature otherwise unexpected behavior would happen.
- Android smartphone equipped with one of below Qualcomm mobile SoCs is required for verify/running ggml-hexagon backend on Android phone:
- Android 8.0 (2017.08) --- Android 15 (2024.10) and higher versions with <b>ANY</b> mainstream arm64 mobile SoC.
- An Android smartphone equipped with <b>ANY</b> mainstream <b>high-end</b> mobile SoC is highly <b>recommended</b> for the realtime AI-subtitle feature, otherwise unexpected behavior may occur.
- An Android smartphone equipped with one of the below Qualcomm mobile SoCs is required for verifying/running the ggml-hexagon backend on Android phones:
```
Snapdragon 8 Gen 2
Snapdragon 8 Gen 3
Snapdragon 8 Elite(aka 8 Gen 4)
Snapdragon 8 Elite Gen 5(aka 8 Gen 5)
Snapdragon 8 Elite (aka 8 Gen 4)
Snapdragon 8 Elite Gen 5 (aka 8 Gen 5)
```


### Screenshots

here is a short video to demostrate realtime AI subtitle by running the great & excellent & amazing<a href="https://github.com/ggerganov/whisper.cpp"> whisper.cpp </a> on an Android phone equipped with Qualcomm Snapdragon 8Gen3 mobile SoC - <b>fully offline, on-device</b>.
Here is a short video to demonstrate realtime AI subtitle by running the great & excellent & amazing <a href="https://github.com/ggerganov/whisper.cpp"> whisper.cpp </a> on an Android phone equipped with Qualcomm Snapdragon 8Gen3 mobile SoC - <b>fully offline, on-device</b>.

https://github.com/zhouwg/kantv/assets/6889919/2fabcb24-c00b-4289-a06e-05b98ecd22b8

----

a screenshot to demostrate multi-modal inference by running the magic <a href="https://github.com/ggerganov/llama.cpp"> llama.cpp </a> on an Android phone equipped with Qualcomm Snapdragon 8Elite mobile SoC - <b>fully offline, on-device</b>.
A screenshot to demonstrate multi-modal inference by running the magic <a href="https://github.com/ggerganov/llama.cpp"> llama.cpp </a> on an Android phone equipped with Qualcomm Snapdragon 8Elite mobile SoC - <b>fully offline, on-device</b>.

![Image](https://github.com/user-attachments/assets/c406951a-383a-4943-a58d-cda401148f9e)

----
a screenshot to demostrate realtime-video-recognition via [MTMD from llama.cpp](https://github.com/ggml-org/llama.cpp/blob/master/docs/multimodal.md) + a lightweight multimodal model [SmolVLM2-256M from Huggingface](https://huggingface.co/HuggingFaceTB/SmolVLM2-256M-Video-Instruct) on an Android phone equipped with Qualcomm Snapdragon 8Elite mobile SoC - <b>fully offline, on-device</b>.
A screenshot to demonstrate realtime-video-recognition via [MTMD from llama.cpp](https://github.com/ggml-org/llama.cpp/blob/master/docs/multimodal.md) + a lightweight multimodal model [SmolVLM2-256M from Huggingface](https://huggingface.co/HuggingFaceTB/SmolVLM2-256M-Video-Instruct) on an Android phone equipped with Qualcomm Snapdragon 8Elite mobile SoC - <b>fully offline, on-device</b>.

![Image](https://github.com/user-attachments/assets/35841e4d-150f-4163-bc58-ada1e9b1a065)

<details>
<summary>some other screenshots</summary>
<ol>

![Image](https://github.com/user-attachments/assets/d9c9bc39-d0d8-4d50-b74d-59152de28d6d)

![Image](https://github.com/user-attachments/assets/025a8ff0-7584-4df2-97a5-f4e655a52e0f)


----

a screenshot to demostrate ASR inference by running the excellent <a href="https://github.com/ggerganov/whisper.cpp"> whisper.cpp </a> on an Android phone equipped with Qualcomm Snapdragon 8Gen3 mobile SoC - <b>fully offline, on-device</b>.

![Image](https://github.com/user-attachments/assets/46856bf2-cc4b-4b0a-9209-d07825fba2e7)


----
a screenshot to demostrate download LLM model in APK.

![1213951738](https://github.com/user-attachments/assets/5a0a965e-1752-475e-a2c1-63e6f60a9009)
![1242080159](https://github.com/user-attachments/assets/32586234-4b2c-4d43-b0ab-498c56de44b3)

</ol>
</details>




### Docs
- [How to build](./docs/how-to-build.md)
Expand All @@ -97,17 +81,16 @@ a screenshot to demostrate download LLM model in APK.
- [ChangeLog](./release/README.md)
- [ggml-hexagon:history of ggml-hexagon](https://github.com/zhouwg/ggml-hexagon/discussions/18)
- [ggml-hexagon:high-level data path of ggml-hexagon](https://github.com/zhouwg/ggml-hexagon/discussions/33)
- [Roadmap](https://github.com/zhouwg/kantv/discussions/262)


### Contribution

Report issue in Android phone equipped with <b>mainstream</b> mobile SoC or submit PR to this project is greatly welcomed.
Reporting issues on Android phones equipped with <b>mainstream</b> mobile SoCs or submitting PRs to this project is greatly appreciated.

I use [GitHub issues](https://github.com/zhouwg/kantv/issues) for tracking feature requests and issue reports, please see [how to submit issue in this project ](https://github.com/zhouwg/kantv/issues/1).
I use [GitHub issues](https://github.com/zhouwg/kantv/issues) for tracking feature requests and issue reports, please see [how to submit an issue in this project](https://github.com/zhouwg/kantv/issues/1).

<!--
comment out this section because some contributors in the upstream project might-be don't want to be appeared here
comment out this section because some contributors in the upstream project might not want to appear here

### Contributors

Expand All @@ -118,37 +101,8 @@ comment out this section because some contributors in the upstream project might

### Special Acknowledgement

<ul>AI inference framework

<ul>
<li>
<a href="https://github.com/ggml-org/ggml">GGML</a>
</li>


</ul>

</ul>

<ul>AI application engine

<ul>
<li>
ASR engine <a href="https://github.com/ggml-org/whisper.cpp">whisper.cpp</a>
</li>

<li>
LLM engine <a href="https://github.com/ggml-org/llama.cpp">llama.cpp</a>
</li>

<li>
CV engine <a href="https://github.com/nihui/opencv-mobile">opencv-mobile</a>
</li>

<li>
MTMD(multimodal) engine <a href="https://github.com/ggml-org/llama.cpp/blob/master/tools/mtmd/README.md">MTMD subsystem in llama.cpp</a>
</li>

</ul>

</ul>
- Inference engine [GGML](https://github.com/ggml-org/ggml)
- ASR engine [whisper.cpp](https://github.com/ggml-org/whisper.cpp)
- LLM engine [llama.cpp](https://github.com/ggml-org/llama.cpp)
- CV engine [opencv-mobile](https://github.com/nihui/opencv-mobile)
- MTMD (multimodal) engine [MTMD subsystem in llama.cpp](https://github.com/ggml-org/llama.cpp/blob/master/tools/mtmd/README.md)
4 changes: 2 additions & 2 deletions android/constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ project.ext {
appTargetSdkVersion = 29

//version and version code of KanTV Android APP
releaseVersion = '1.6.10'
releaseVersionCode = 1000610
releaseVersion = '1.7.0'
releaseVersionCode = 1007000

//version and version code of internal customized Exoplayer2
releaseVersionExoplayer = '2.15.1'
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GROUP=KanTV.AI

# http://central.sonatype.org/pages/requirements.html
POM_USER_ORG=KanTV.AI
POM_DESCRIPTION=workbench for study and practise on-device AI technology in real scenario with online-TV on Android phone, powered by llama.cpp & whisper.cpp & stable-diffusion.cpp and FFmpeg and original made ggml-hexagon
POM_DESCRIPTION=workbench for study and practise on-device AI technology in real scenario with online-TV on Android phone, powered by llama.cpp & whisper.cpp and FFmpeg and original made ggml-hexagon
POM_URL=https://github.com/zhouwg/kantv
POM_SCM_URL=https://github.com/zhouwg/kantv
POM_LICENSE_NAME=MIT license
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void initAIModels() {
}

try {
KANTVLibraryLoader.load("ggml-jni");
KANTVLibraryLoader.load("kantv-ai");
KANTVLog.g(TAG, "cpu core counts:" + ggmljava.get_cpu_core_counts());
} catch (Exception e) {
KANTVLog.g(TAG, "failed to initialize ggml jni");
Expand Down
Loading