# minicap
Minicap provides a socket interface for streaming realtime screen capture data out of Android devices. It is meant to be used as a component in a larger program and is therefore not immensely useful just by itself. For example, it is being used in [STF](https://github.com/openstf/stf) for remote control.
Minicap works without root if started via [ADB](http://developer.android.com/tools/help/adb.html) on SDK 28 (Android 9.0) and lower. The lowest SDK level we build for is 9 (i.e. Android 2.3). Minicap also works on Android Wear. Developer previews are, in general, supported once Google releases the source code for that release. _Only the latest Developer Preview is supported, and only until there's a stable release._ Emulators are not supported. Note that Android 3.x is not supported since those versions were never open sourced.
To capture the screen we currently use two methods. For older Android versions we use the ScreenshotClient, a private API in AOSP. For newer versions we use a virtual display, which also requires access to private APIs. The frames are then encoded using SIMD-enabled [libjpeg-turbo](http://libjpeg-turbo.virtualgl.org/) and sent over a socket interface. A planned future improvement to allow for even higher FPS is to use MediaRecorder and friends to take advantage of hardware encoding.
In principle, every device should work. However, since minicap relies on private APIs, some may not. Please let us know by creating a GitHub issue about that device.
The project consists of two parts. There's the main binary that can be built using NDK alone. The other part is a shared library that's built for each SDK level and each architecture inside the AOSP source tree. We ship precompiled libraries in this repo, but any modifications to the code used by these shared libraries require a recompile against the corresponding AOSP branches. This can be a major pain, but we have several utilities to help with the ordeal. If you're interested in that, [read the build instructions here](jni/minicap-shared/README.md).
## Features
* Usable to very smooth FPS depending on device. Older, weaker devices running an old version of Android can reach 10-20 FPS. Newer devices running recent versions of Android can usually reach 30-40 FPS fairly easily, but there are some exceptions. For maximum FPS we recommend running minicap at half the real vertical and horizontal resolution.
* Decent and usable but non-zero latency. Depending on encoding performance and USB transfer speed it may be one to a few frames behind the physical screen.
* On Android 4.2+, frames are only sent when something changes on the screen. On older versions frames are sent as a constant stream, whether there are changes or not.
* Easy socket interface.
## Requirements
* [NDK](https://developer.android.com/tools/sdk/ndk/index.html), Revision 10e (May 2015)
* [make](http://www.gnu.org/software/make/)
## Building
We include [libjpeg-turbo as a Git submodule](https://github.com/openstf/android-libjpeg-turbo), so first make sure you've fetched it.
```
git submodule init
git submodule update
```
You're now ready to proceed.
Building requires [NDK](https://developer.android.com/tools/sdk/ndk/index.html), and is known to work with at least with NDK Revision 10e (May 2015). Older versions do not work due to the lack of `.asm` file support for x86_64. **Important note: NDK 15 no longer supports Android platforms earlier than SDK level 14. This means that if compiled on NDK 15 or later, the binaries may or may not work on earlier platforms (e.g. Android 2.3, Android 2.3.3).**
Then it's simply a matter of invoking `ndk-build`.
```
ndk-build
```
You should now have the binaries available in `./libs`.
If you've modified the shared library, you'll also need to [build that](jni/minicap-shared/README.md).
## Running
You'll need to [build](#building) first.
### The easy way
You can then use the included [run.sh](run.sh) script to run the right binary on your device. It will make sure the correct binary and shared library get copied to your device. If you have multiple devices connected, set `ANDROID_SERIAL` before running the script.
```bash
# Run a preliminary check to see whether your device will work
./run.sh autosize -t
# Check help
./run.sh autosize -h
# Start minicap
./run.sh autosize
```
_The `autosize` command is for selecting the correct screen size automatically. This is done by the script instead of the binary itself. To understand why this is necessary, read the manual instructions below._
Finally we simply need to create a local forward so that we can connect to the socket.
```bash
adb forward tcp:1313 localabstract:minicap
```
Now you'll be able to connect to the socket locally on port 1313.
Then just see [usage](#usage) below.
### The hard way
To run manually, you have to first figure out which ABI your device supports:
```bash
ABI=$(adb shell getprop ro.product.cpu.abi | tr -d '\r')
```
_Note that as Android shell always ends lines with CRLF, you'll have to remove the CR like above or the rest of the commands will not work properly._
_Also note that if you've got multiple devices connected, setting `ANDROID_SERIAL` will make things quite a bit easier as you won't have to specify the `-s <serial>` option every time._
Now, push the appropriate binary to the device:
```bash
adb push libs/$ABI/minicap /data/local/tmp/
```
Note that for SDK <16, you will have to use the `minicap-nopie` executable which comes without [PIE](http://en.wikipedia.org/wiki/Position-independent_code#Position-independent_executables) support. Check [run.sh](run.sh) for a scripting example.
The binary enough is not enough. We'll also need to select and push the correct shared library to the device. This can be done as follows.
```bash
SDK=$(adb shell getprop ro.build.version.sdk | tr -d '\r')
adb push jni/minicap-shared/aosp/libs/android-$SDK/$ABI/minicap.so /data/local/tmp/
```
At this point it might be useful to check the usage:
```bash
adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -h
```
Note that you'll need to set `LD_LIBRARY_PATH` every time you call minicap or it won't find the shared library.
Also, you'll need to specify the size of the display and the projection every time you use minicap. This is because the private APIs we would have to use to access that information segfault on many Samsung devices (whereas minicap itself runs fine). The [run.sh](run.sh) helper script provides the `autosize` helper as mentioned above.
So, let's assume that your device has a 1080x1920 screen. First, let's run a quick check to see if your device is able to run the current version of minicap:
```bash
adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0 -t
```
_The format of the -P argument is: {RealWidth}x{RealHeight}@{VirtualWidth}x{VirtualHeight}/{Orientation}. The "virtual" size is the size of the desired projection. The orientation argument tells minicap what the current orientation of the device is (in degrees), which is required so that we can report the correct orientation over the socket interface to the frame consumer. One way to get the current orientation (or rotation) is [RotationWatcher.apk](https://github.com/openstf/RotationWatcher.apk)._
If the command outputs "OK", then everything should be fine. If instead it segfaults (possibly after hanging for a while), your device is not supported and [we'd like to know about it](https://github.com/openstf/minicap/issues).
Finally, let's start minicap. It will start listening on an abstract unix domain socket.
```bash
adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0
```
Now we simply need to create a local forward so that we can connect to the socket.
```bash
adb forward tcp:1313 localabstract:minicap
```
Now you can connect to the socket using the local port. Note that currently **only one connection at a time is s
没有合适的资源?快使用搜索试试~ 我知道了~
minicap.zip
共1131个文件
o:282个
d:234个
c:93个
需积分: 16 16 下载量 156 浏览量
2019-08-16
13:10:32
上传
评论
收藏 35.27MB ZIP 举报
温馨提示
Minicap源码已经过ndk-build编译,使用步骤可以参考https://www.jianshu.com/p/777af34b4f21,其中编译过程已经给大家做好了
资源详情
资源评论
资源推荐
收起资源包目录
minicap.zip (1131个子文件)
cjpeg.1 13KB
djpeg.1 9KB
jpegtran.1 8KB
wrjpgcom.1 3KB
rdjpgcom.1 2KB
libjpeg-turbo.a 6.4MB
libjpeg-turbo.a 5.84MB
libjpeg-turbo.a 3.39MB
libjpeg-turbo.a 2.79MB
libminicap-common.a 300KB
libminicap-common.a 298KB
libminicap-common.a 194KB
libminicap-common.a 189KB
configure.ac 18KB
Makefile.am 29KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 100B
jidctint-sse2.asm 35KB
jidctint-sse2-64.asm 35KB
jidctint-mmx.asm 33KB
jidctred-mmx.asm 27KB
jfdctint-sse2.asm 27KB
jdsample-sse2.asm 26KB
jfdctint-sse2-64.asm 26KB
jdsample-mmx.asm 25KB
jidctflt-sse.asm 25KB
jfdctint-mmx.asm 25KB
jidctred-sse2.asm 23KB
jdsample-sse2-64.asm 23KB
jidctred-sse2-64.asm 22KB
jidctflt-sse2.asm 21KB
jidctfst-sse2.asm 21KB
jdmrgext-sse2.asm 21KB
jidctflt-sse2-64.asm 20KB
jidctfst-sse2-64.asm 20KB
jdmrgext-sse2-64.asm 20KB
jidctfst-mmx.asm 20KB
jccolext-sse2.asm 19KB
jdcolext-sse2.asm 18KB
jccolext-sse2-64.asm 18KB
jdmrgext-mmx.asm 18KB
jfdctfst-sse2.asm 17KB
jdcolext-sse2-64.asm 17KB
jidctflt-3dn.asm 17KB
jfdctfst-sse2-64.asm 17KB
jccolext-mmx.asm 17KB
jfdctfst-mmx.asm 15KB
jdcolext-mmx.asm 15KB
jfdctflt-sse.asm 15KB
jfdctflt-sse-64.asm 14KB
jcgryext-sse2.asm 14KB
jcgryext-sse2-64.asm 13KB
jcgryext-mmx.asm 12KB
jfdctflt-3dn.asm 12KB
jcsample-sse2.asm 10KB
jcsample-mmx.asm 9KB
jquant-mmx.asm 9KB
jcsample-sse2-64.asm 9KB
jquant-3dn.asm 9KB
jquant-sse.asm 8KB
jquanti-sse2.asm 7KB
jquanti-sse2-64.asm 6KB
jquantf-sse2.asm 6KB
jquantf-sse2-64.asm 5KB
jdmerge-sse2-64.asm 4KB
jdmerge-sse2.asm 4KB
jdmerge-mmx.asm 4KB
jccolor-mmx.asm 4KB
jccolor-sse2-64.asm 4KB
jccolor-sse2.asm 4KB
jdcolor-sse2-64.asm 3KB
jdcolor-sse2.asm 3KB
jdcolor-mmx.asm 3KB
jcgray-mmx.asm 3KB
jcgray-sse2-64.asm 3KB
jcgray-sse2.asm 3KB
jsimdcpu.asm 3KB
nightshot_iso_100.bmp 81KB
vgl_6548_0026a.bmp 36KB
vgl_5674_0098.bmp 34KB
vgl_6434_0018a.bmp 34KB
jidctint.c 102KB
transupp.c 61KB
turbojpeg.c 60KB
jquant2.c 48KB
jmemmgr.c 43KB
jdmarker.c 42KB
turbojpeg-jni.c 41KB
jchuff.c 33KB
jquant1.c 32KB
tjbench.c 30KB
jcarith.c 29KB
jdcolor.c 28KB
jsimd_i386.c 28KB
jdmaster.c 27KB
jsimd_mips.c 27KB
jdcoefct.c 26KB
jcphuff.c 25KB
jdhuff.c 25KB
共 1131 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
小源子2016
- 粉丝: 99
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- yolo目标检测项目实验
- downloadFile-1.hc
- Centos7.9环境下离线安装开源版Nginx(亲测版)
- C++课程设计:基于Qt的航班信息管理系统
- ADS7822UVerilog驱动,前面传的有点问题
- 基于python的高性能爬虫程序,使用了多线程+缓存+xpath实现的,这里以彼-岸图库为例,实现,仅用于学习交流
- 中分辨率成像光谱仪(MODIS)烧毁面积产品信息MODIS-C6-BA-User-Guide-1.2.pdf
- Screenshot_20240427_172613_com.huawei.browser.jpg
- 关于学习Python的相关资源网站链接及相关介绍.docx
- (HAL库)基于STM32F103C8T6的温控PID系统[Dht11、ESP8266、无线透传、L298N……]
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0