Code Monkey home page Code Monkey logo

minicap's Introduction

Warning

This project along with other ones in OpenSTF organisation is provided as is for community, without active development.

You can check any other forks that may be actively developed and offer new/different features here.

Active development has been moved to DeviceFarmer organisation.

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 for remote control.

Minicap works without root if started via ADB 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 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.

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, Revision 10e (May 2015)
  • make

Building

We include libjpeg-turbo as a Git submodule, so first make sure you've fetched it.

git submodule init
git submodule update

You're now ready to proceed.

Building requires NDK, 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.

Running

You'll need to build first.

The easy way

You can then use the included 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.

# 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.

adb forward tcp:1313 localabstract:minicap

Now you'll be able to connect to the socket locally on port 1313.

Then just see usage below.

The hard way

To run manually, you have to first figure out which ABI your device supports:

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:

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 support. Check 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.

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:

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 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:

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.

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.

Finally, let's start minicap. It will start listening on an abstract unix domain socket.

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.

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 supported. It doesn't really make sense to have more than one connection anyway, as the USB bus would get saturated very quickly. So, let's connect.

nc localhost 1313

This will give you binary output that will be explained in the next section.

Usage

It is assumed that you now have an open connection to the minicap socket. If not, follow the instructions above.

The minicap protocol is a simple push-based binary protocol. When you first connect to the socket, you get a global header followed by the first frame. The global header will not appear again. More frames keep getting sent until you stop minicap.

Global header binary format

Appears once.

Bytes Length Type Explanation
0 1 unsigned char Version (currently 1)
1 1 unsigned char Size of the header (from byte 0)
2-5 4 uint32 (low endian) Pid of the process
6-9 4 uint32 (low endian) Real display width in pixels
10-13 4 uint32 (low endian) Real display height in pixels
14-17 4 uint32 (low endian) Virtual display width in pixels
18-21 4 uint32 (low endian) Virtual display height in pixels
22 1 unsigned char Display orientation
23 1 unsigned char Quirk bitflags (see below)

Quirk bitflags

Currently, the following quirks may be reported:

Value Name Explanation
1 QUIRK_DUMB Frames will get sent even if there are no changes from the previous frame. Informative, doesn't require any actions on your part. You can limit the capture rate by reading frame data slower in your own code if you wish.
2 QUIRK_ALWAYS_UPRIGHT The frame will always be in upright orientation regardless of the device orientation. This needs to be taken into account when rendering the image.
4 QUIRK_TEAR Frame tear might be visible. Informative, no action required. Neither of our current two methods exhibit this behavior.

Frame binary format

Appears a potentially unlimited number of times.

Bytes Length Type Explanation
0-3 4 uint32 (low endian) Frame size in bytes (=n)
4-(n+4) n unsigned char[] Frame in JPG format

Debugging

You can use gdb to debug more complex issues. It is assumed that you already know how to use it. Here's how to get it running.

First, if you haven't already, make sure to build your project with the NDK_DEBUG option enabled, as follows.

ndk-build NDK_DEBUG=1

This will create gdb.setup and the gdb binaries themselves.

If you don't have NDK_ROOT set up yet, do it now like below. You may have to change the path, the sample path below works on OS X with Android Studio's NDK bundle (which you'll have to install as well).

export NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"

Next, be sure that minicap is actually running. Just running ./run.sh autosize is enough.

Finally, you should be able to just run ./ndk.sh in a separate shell (you'll have to keep minicap running at the same time). It will pull all necessary libraries from the device to ease debugging, and you should end up at a functioning gdb shell. The ndk.sh script has been adapted from ndk-gdb for stand-alone binaries.

Improvements are welcome.

Contributing

As a small disclaimer, minicap was the first time the author used C++, so even any non-functional changes to make the code more idiomatic (preferably without introducing new dependencies) are also very welcome, in addition to bug fixes and new features.

See CONTRIBUTING.md.

License

See LICENSE.

Copyright © The OpenSTF Project. All Rights Reserved.

minicap's People

Contributors

koral-- avatar pcrepieux avatar qmfrederik avatar sorccu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minicap's Issues

autosize do not work on SDK 19

Thanks for the awesome project.

I test run.sh on a google glass running SDK 19. But 'autosize' do not work. I find the following codes always return empty strings.

args=
if [ "$1" = "autosize" ]; then
  set +o pipefail
  size=$(adb shell dumpsys window | grep -Eo 'init=\d+x\d+' | head -1 | cut -d= -f 2)
  if [ "$size" = "" ]; then
    w=$(adb shell dumpsys window | grep -Eo 'DisplayWidth=\d+' | head -1 | cut -d= -f 2)
    h=$(adb shell dumpsys window | grep -Eo 'DisplayHeight=\d+' | head -1 | cut -d= -f 2)
    size="${w}x${h}"
  fi
  args="-P $size@$size/0"
  set -o pipefail
  shift
fi

I try to fix it by changing the code to

args=
if [ "$1" = "autosize" ]; then
  set +o pipefail
  size=$(adb shell dumpsys window | grep -Eo 'init=\d+x\d+' | head -1 | cut -d= -f 2)
  if [ "$size" = "" ]; then
    size=$(adb shell wm size| cut -d: -f2 |tr -d " \n\t\r")
  fi
  args="-P $size@$size/0"
  set -o pipefail
  shift
fi

I'm not sure if wm size can return the exact same thing with dumsys window, if not, please correct me.

Thank you.

run.sh can not execute correctly in sdk 15

i run the run.sh in sdk 15 machine, but i find the following codes always.

cvt1512:minicap cvter$ ./run.sh autosize
+ ndk-build
[armeabi-v7a] Install        : minicap => libs/armeabi-v7a/minicap
[armeabi-v7a] Install        : minicap-nopie => libs/armeabi-v7a/minicap-nopie
[armeabi-v7a] Install        : minicap.so => libs/armeabi-v7a/minicap.so
[arm64-v8a] Install        : minicap => libs/arm64-v8a/minicap
[arm64-v8a] Install        : minicap-nopie => libs/arm64-v8a/minicap-nopie
[arm64-v8a] Install        : minicap.so => libs/arm64-v8a/minicap.so
[x86] Install        : minicap => libs/x86/minicap
[x86] Install        : minicap-nopie => libs/x86/minicap-nopie
[x86] Install        : minicap.so => libs/x86/minicap.so
[x86_64] Install        : minicap => libs/x86_64/minicap
[x86_64] Install        : minicap-nopie => libs/x86_64/minicap-nopie
[x86_64] Install        : minicap.so => libs/x86_64/minicap.so
++ adb shell getprop ro.product.cpu.abi
++ tr -d '\r'
+ abi=armeabi-v7a
++ adb shell getprop ro.build.version.sdk
++ tr -d '\r'
+ sdk=15
++ adb shell getprop ro.build.version.release
++ tr -d '\r'
+ rel=4.0.4
+ (( 15 >= 16 ))
+ bin=minicap-nopie
+ args=
+ '[' autosize = autosize ']'
+ set +o pipefail
++ adb shell dumpsys window
++ grep -Eo 'init=\d+x\d+'
++ head -1
++ cut -d= -f 2
+ size=1280x720
+ '[' 1280x720 = '' ']'
+ args='-P 1280x720@1280x720/0'
+ set -o pipefail
+ shift
+ dir=/data/local/tmp/minicap-devel
+ adb shell 'mkdir /data/local/tmp/minicap-devel 2>/dev/null'
+ adb push libs/armeabi-v7a/minicap-nopie /data/local/tmp/minicap-devel
211 KB/s (349928 bytes in 1.612s)
+ '[' -e jni/minicap-shared/aosp/libs/android-4.0.4/armeabi-v7a/minicap.so ']'
+ adb push jni/minicap-shared/aosp/libs/android-15/armeabi-v7a/minicap.so /data/local/tmp/minicap-devel
112 KB/s (5700 bytes in 0.049s)
+ adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap-nopie -P 1280x720@1280x720/0
link_image[1936]: 28941 could not load needed library 'minicap.so' for '/data/local/tmp/minicap-devel/minicap-nopie' (link_image[1936]: 28941 could not load needed library 'libutils.so' for 'minicap.so' (link_image[1936]: 28941 could not load needed library 'libz.so' for 'libutils.so' (link_image[1936]: 28941 could not load needed library 'libc.so.6' for 'libz.so' (load_library[1091]: Library 'libc.so.6' not found))))CANNOT LINK EXECUTABLE
+ adb shell rm -r /data/local/tmp/minicap-devel

./run.sh autosize -t works, but ./run.sh autosize abort

The ./run.sh autosize -t will return a 'ok' in the end of the log.
But ./run.sh autosize will return a terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted in the end. I have no idea why this happened. Any idea about how to fix this problem would be great.
And the full fail log is this:
+ ndk-build NDK_DEBUG=1
°armeabi-v7aé Gdbserver : °arm-linux-androideabié libs/armeabi-v7a/gdbserver
°armeabi-v7aé Gdbsetup : libs/armeabi-v7a/gdb.setup
°arm64-v8aé Gdbserver : °aarch64-linux-androidé libs/arm64-v8a/gdbserver
°arm64-v8aé Gdbsetup : libs/arm64-v8a/gdb.setup
°x86é Gdbserver : °i686-linux-androidé libs/x86/gdbserver
°x86é Gdbsetup : libs/x86/gdb.setup
°x86_64é Gdbserver : °x86_64-linux-androidé libs/x86_64/gdbserver
°x86_64é Gdbsetup : libs/x86_64/gdb.setup
°armeabi-v7aé Install : minicap => libs/armeabi-v7a/minicap
°armeabi-v7aé Install : minicap-nopie => libs/armeabi-v7a/minicap-nopie
°armeabi-v7aé Install : minicap.so => libs/armeabi-v7a/minicap.so
°arm64-v8aé Install : minicap => libs/arm64-v8a/minicap
°arm64-v8aé Install : minicap-nopie => libs/arm64-v8a/minicap-nopie
°arm64-v8aé Install : minicap.so => libs/arm64-v8a/minicap.so
°x86é Install : minicap => libs/x86/minicap
°x86é Install : minicap-nopie => libs/x86/minicap-nopie
°x86é Install : minicap.so => libs/x86/minicap.so
°x86_64é Install : minicap => libs/x86_64/minicap
°x86_64é Install : minicap-nopie => libs/x86_64/minicap-nopie
°x86_64é Install : minicap.so => libs/x86_64/minicap.so
++ adb shell getprop ro.product.cpu.abi
++ tr -d 'çr'
+ abi=arm64-v8a
++ adb shell getprop ro.build.version.sdk
++ tr -d 'çr'
+ sdk=23
++ adb shell getprop ro.build.version.release
++ tr -d 'çr'
+ rel=6.0.1
+ (( 23 >= 16 ))
+ bin=minicap
+ args=
+ '°' autosize = autosize 'é'
+ set +o pipefail
++ adb shell dumpsys window
++ grep -Eo 'init=çd+xçd+'
++ head -1
++ cut -d= -f 2
+ size=1080x1920
+ '°' 1080x1920 = '' 'é'
+ args='-P 1080x1920§1080x1920/0'
+ set -o pipefail
+ shift
+ dir=/data/local/tmp/minicap-devel
+ adb shell 'mkdir /data/local/tmp/minicap-devel 2>/dev/null òò true'
+ adb push libs/arm64-v8a/minicap /data/local/tmp/minicap-devel
°100%é /data/local/tmp/minicap-devel/minicap
+ '°' -e jni/minicap-shared/aosp/libs/android-6.0.1/arm64-v8a/minicap.so 'é'
+ adb push jni/minicap-shared/aosp/libs/android-23/arm64-v8a/minicap.so /data/local/tmp/minicap-devel
°100%é /data/local/tmp/minicap-devel/minicap.so
+ adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1080x1920§1080x1920/0
PID: 2594
INFO: Using projection 1080x1920§1080x1920/0
INFO: (external/MY_minicap/src/minicap_23.cpp:240) Creating SurfaceComposerClient
INFO: (external/MY_minicap/src/minicap_23.cpp:243) Performing SurfaceComposerClient init check
INFO: (external/MY_minicap/src/minicap_23.cpp:250) Creating virtual display
INFO: (external/MY_minicap/src/minicap_23.cpp:256) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_23.cpp:261) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_23.cpp:265) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_23.cpp:269) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 6268932 bytes for JPG encoder
terminate called after throwing an instance of 'std::bad_cast'
what(): std::bad_cast
Aborted

minicap disconnects after connect to device

Thanks for the awesome project.

Device info (with nodejs module - adbkit)
'ro.product.cpu.abi': 'armeabi-v7a',
'ro.product.manufacturer': 'Sony',
'ro.product.model': 'Xperia',

I use js file from your examples directory
I added some code to file

stream.on('end',function(){
console.info('disconnected',arguments);
});

I run minicap with log

INFO: Using projection 1440x2570@269x480/0
INFO: (external/MY_minicap/src/minicap_22.cpp:240) Creating SurfaceComposerClient
INFO: (external/MY_minicap/src/minicap_22.cpp:243) Performing SurfaceComposerClient init check
INFO: (external/MY_minicap/src/minicap_22.cpp:250) Creating virtual display
INFO: (external/MY_minicap/src/minicap_22.cpp:256) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_22.cpp:261) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_22.cpp:265) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_22.cpp:269) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11130372 bytes for JPG encoder

Then i run
node example.js
When web page is loaded - in console fire event 'end'
and no images in browser

Can we add a option to reduce the resolution of images?

Because the resolution of lots of device is 2K or higher. This will make amount of data from the device to reduce the performance. In fact, We dont need the same resolution of the device some times.
So can we add a option to reduce the resolution of images?

minicap-shared compile

i changed and want to compile minicap-shared source code on aosp M version, what should i do?

run minicap error on android 19 version

device info:
CPU Rockchip rk3128
GPU ARM Mali-400MP2
RAM 1G
System Android 4.4.4

When I run minicap on device, system will become not fluent.After 1~3s,system will reboot.
From log, we got this message:
05-13 15:00:20.672 W/SurfaceFlinger( 117): [minicap] EGL called dequeueBuffer with !async despite eglSwapInterval(0)

How can I solve this problem?

Minicap Stream Orientation

Hi,

I can run the example following the sample instructions. However, I found there is one issue that the command orientation is hard code for the first run minicap binary. Sometimes, Android app 1 launches at Landscape while app 2 launches at Portrait. Is there any way to make it adapt automatically?

adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1440x2560@1440x2560/0 (0 Portrait)

Thanks,
Harry

Can you provider a example

Can you provider a example about blow command

adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1440x2560@1440x2560/0 -s

how to parser the data?

Android 7

Hi guys,

Are you planning to support Android 7 or have you tested if it is working with it?

Thanks

can't runing ....

i build on windows7 use NDKR10D and AOSP is android 4.4

the code like this :

android::sp<android::SurfaceComposerClient> sc = new android::SurfaceComposerClient();
if ((err = sc->initCheck()) != android::NO_ERROR) {
  MCERROR("Unable to initialize SurfaceComposerClient");
  return err;
}

all ways return error , why ? i checked the android4.4 source , and class SurfaceComposerClient:

SurfaceComposerClient::SurfaceComposerClient()
: mStatus(NO_INIT), mComposer(Composer::getInstance())
{
}

status_t SurfaceComposerClient::initCheck() const {
return mStatus;
}

the code means , initCheck is allways return NO_INIT .

screen freeze after starting minicap

phone:

  • manufacturer: 'OPPO'
  • model: 'OPPO X9007'
  • version: '4.3'
  • abi: 'armeabi-v7a'
  • sdk: '18'

after starting minicap on device manually:

F:\>adb shell
shell@X9007:/ $ cd /data/local/tmp
cd /data/local/tmp
shell@X9007:/data/local/tmp $ LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/mi
nicap -P 1080x1920@1080x1920/0
cal/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0                      <
PID: 25100
INFO: Using projection 1080x1920@1080x1920/0
INFO: (external/MY_minicap/src/minicap_18.cpp:239) Creating SurfaceComposerClien
t
INFO: (external/MY_minicap/src/minicap_18.cpp:242) Performing SurfaceComposerCli
ent init check
INFO: (external/MY_minicap/src/minicap_18.cpp:249) Creating virtual display
INFO: (external/MY_minicap/src/minicap_18.cpp:255) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_18.cpp:259) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_18.cpp:264) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_18.cpp:268) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 6268932 bytes for JPG encoder

The whole screen will be frozen immediately, not response to any touch or click gesture.

then close minicap via Ctrl+C. Current application, whatever it is on device, will show ANR message.


For other device(Meizu m1 note). it will be frozen too after a while.
phone info:

  • manufacturer: 'Meizu'
  • model: 'Meizu m1 note'
  • version: '4.4.4'
  • abi: 'armeabi-v7a'
  • sdk: '19'

What is the possible reason for this problem? Both of the two devices use custom android ROM.

Minicap getting blocked while capturing images

Phone Details:

manufacturer: 'Google/Motorola'
model: 'Nexus 6'
version: '7.0'
abi: 'armeabi-v7a'
sdk: '24'

After starting the minicap on the above mentioned device, the minicap is getting blocked and is not returning any output

adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0
PID: 29358
INFO: Using projection 1440x2560@1440x2560/0
INFO: (external/MY_minicap/src/minicap_24.cpp:240) Creating SurfaceComposerClient
INFO: (external/MY_minicap/src/minicap_24.cpp:243) Performing SurfaceComposerClient init check
INFO: (external/MY_minicap/src/minicap_24.cpp:250) Creating virtual display
INFO: (external/MY_minicap/src/minicap_24.cpp:256) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_24.cpp:261) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_24.cpp:265) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_24.cpp:269) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder

The minicap will be blocked at this and will not continue.
What could be possible reason for this?

Segmentation fault when running minicap in SAMSUNG Galaxy note4

Hi, there is segmentation fault when run minicap in galaxy note4.
In README.MD, I see description "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". But I specify the size of the display when I run minicap in galaxy note4.
And what's factor or reason caused this phnomemon. And how to locate the reasons.
Thanks for your any help.

Use inside app without adb

Is it possible to include minicap in an .apk and use it without adb?
Maybe creating a websocket server inside de apk with nanohttpd? Any suggestions?
Thank you

How to force minicap to publish images?

When the screen does not change,minicap would not send an image.

How to force minicap to publish images?
or What parameters can it Interval not more than 3 seconds?

Keep frame always landscape

Hi,

Previously, I asked a question on frame for different rotation. You suggested restart the minicap server when rotation is changed.

I am wondering whether there is a way to keep frame always align for one rotation, like landscape, even for portrait app or landscape app. What I saw is the frame is just half for portrait app when the desired rotation of starting minicap server is 90 degree; however, it shows correctly for landscape apps.

Thanks,
Harry

what is the possible reason of " Unable to initialize SurfaceComposerClient " ?

my jni code :

android::spandroid::SurfaceComposerClient sc = new android::SurfaceComposerClient();

is failed .

i don't know why ??
look up the android source , i wirte the test code like this :

//test code
sp<ISurfaceComposer> sm(ComposerService::getComposerService());
if (sm != 0) {
    sp<ISurfaceComposerClient> conn = sm->createConnection();
    if (conn != 0) {
        LOG("init success ... ");
        return 1;
    }
    LOG("conn == 0");
    return -1;
}

the run result is : conn == 0 .
my question is why createConnection is failed ?
is authority ? is thread ?

i use the code in apk with JNI .

Run minicap on set top box without monitor

Hello,

I have try to use minicap with -s option on Minix (Android set top box) to get a screenshot file, everything work perfectly. It take about 150 ~ 200 ms per image, but when I disconnect a monitor minicap will take more time for a screenshot (500 ~ 600 ms per image).

How can I solve this problem?

Thank you for your awesome works.

where is turbojpeg.h

when i execution ./run.sh -P 720x1280@720x1280/0 as the README.md in the example folder

it report back:
In file included from jni/minicap/JpgEncoder.cpp:3:0:
jni/minicap/JpgEncoder.hpp:4:23: fatal error: turbojpeg.h: No such file or directory
#include <turbojpeg.h>

I realized that i need the libjpeg-turbo

but how did i use it ? just down and make it or the other way?

I saw the prompt that “We include libjpeg-turbo as a Git submodule, so first make sure you've fetched it.”

but i did not understand.
I am a novice. please help me
thank you

Use minicap command to take screenshot fail.

Fail to used command "adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 480x854@480x854/0 -t" to take screenshot .

The output info is "/system/bin/sh: /data/local/tmp/minicap: can't execute: Permission denied".

How to solve this problem.

3Q !

Minicap did not accept real display info

I am getting the following error in my Minicap use on Nexus 6 (Android 7).

Error:
INFO: Using projection 1440x2560@360x640/0
ERROR: (jni/minicap/minicap.cpp:347: errno: None) Minicap did not accept real display info
INFO: (external/MY_minicap/src/minicap_24.cpp:284) Destroying virtual display

CPU : armeabi-v7a

Command which I am using after which I am getting the error:

         adb  shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@360x640/0   

Run "run.sh" exception

$ ./run.sh -h for help

  • ndk-build NDK_DEBUG=1
    [armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.9] libs/armeabi-v7a/gdbserver
    [armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup
    [arm64-v8a] Gdbserver : [aarch64-linux-android-4.9] libs/arm64-v8a/gdbserver
    [arm64-v8a] Gdbsetup : libs/arm64-v8a/gdb.setup
    [x86] Gdbserver : [x86-4.9] libs/x86/gdbserver
    [x86] Gdbsetup : libs/x86/gdb.setup
    [x86_64] Gdbserver : [x86_64-4.9] libs/x86_64/gdbserver
    [x86_64] Gdbsetup : libs/x86_64/gdb.setup
    [armeabi-v7a] Compile++ thumb: minicap-common <= JpgEncoder.cpp
    In file included from jni/minicap/JpgEncoder.cpp:3:0:
    jni/minicap/JpgEncoder.hpp:4:23: fatal error: turbojpeg.h: No such file or directory
    #include <turbojpeg.h>
    ^
    compilation terminated.
    /usr/src/ndk/build/core/build-binary.mk:499: recipe for target 'obj/local/armeabi-v7a/objs-debug/minicap-common/JpgEncoder.o' failed
    make: *** [obj/local/armeabi-v7a/objs-debug/minicap-common/JpgEncoder.o] Error 1

Build minicap for Android N (Preview)

Hi,

I am trying to build minicap for Android N. Is there any instructions on how to do that? I would like to build from AOSO source code.

Thanks a lot!
-Harry

compile the minicap.so

Because of my C disk does not have enough space for aosp, so I have downloaded it into home/srv/aosp directory. Now I try to run the docker command directly, such as: "docker run --rm -a stdout -a stderr -v /home/srv/aosp/android-5.1.0_r1:/aosp -v /tmp/minicap/:/app -v /tmp/minicap/libs/android-22/x86:/artifacts openstf/aosp:jdk7 /aosp.sh build generic-eng minicap". This command means I want to compile the x86 file, but it brought out the armeabi-v7a file. So, how can I build the x86 file, could you give me some suggestions. Thx.

Launching minicap twice = permanent freeze

When launching minicap twice (from two different terminals), then second launch creates and destroy virtual display immediately (which is normal). but it freezes the screen permanently (adb still works). Need to do "adb reboot" to solve situation.

first launch log :

$ ./run.sh -P 1440x2560@1024x600/0
++ tr -d '\r'
++ adb shell getprop ro.product.cpu.abi

  • abi=arm64-v8a
    ++ adb shell getprop ro.build.version.sdk
    ++ tr -d '\r'
  • sdk=23
    ++ tr -d '\r'
    ++ adb shell getprop ro.build.version.release
  • rel=6.0.1
  • (( 23 >= 16 ))
  • bin=minicap
  • dir=/data/local/tmp/minicap-devel
  • adb shell 'mkdir /data/local/tmp/minicap-devel 2>/dev/null || true'
  • adb push libs/arm64-v8a/minicap /data/local/tmp/minicap-devel
    [100%] /data/local/tmp/minicap-devel/minicap
  • '[' -e jni/minicap-shared/aosp/libs/android-6.0.1/arm64-v8a/minicap.so ']'
  • adb push jni/minicap-shared/aosp/libs/android-23/arm64-v8a/minicap.so /data/local/tmp/minicap-devel
    [100%] /data/local/tmp/minicap-devel/minicap.so
  • adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1024x600/0
    PID: 20256
    INFO: Using projection 1440x2560@338x600/0
    INFO: (external/MY_minicap/src/minicap_23.cpp:240) Creating SurfaceComposerClient
    INFO: (external/MY_minicap/src/minicap_23.cpp:243) Performing SurfaceComposerClient init check
    INFO: (external/MY_minicap/src/minicap_23.cpp:250) Creating virtual display
    INFO: (external/MY_minicap/src/minicap_23.cpp:256) Creating buffer queue
    INFO: (external/MY_minicap/src/minicap_23.cpp:261) Creating CPU consumer
    INFO: (external/MY_minicap/src/minicap_23.cpp:265) Creating frame waiter
    INFO: (external/MY_minicap/src/minicap_23.cpp:269) Publishing virtual display
    INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder
  • adb shell rm -r /data/local/tmp/minicap-devel

second log :

$ ./run.sh -P 1440x2560@1024x600/0
++ tr -d '\r'
++ adb shell getprop ro.product.cpu.abi

  • abi=arm64-v8a
    ++ adb shell getprop ro.build.version.sdk
    ++ tr -d '\r'
  • sdk=23
    ++ tr -d '\r'
    ++ adb shell getprop ro.build.version.release
  • rel=6.0.1
  • (( 23 >= 16 ))
  • bin=minicap
  • dir=/data/local/tmp/minicap-devel
  • adb shell 'mkdir /data/local/tmp/minicap-devel 2>/dev/null || true'
  • adb push libs/arm64-v8a/minicap /data/local/tmp/minicap-devel
    [100%] /data/local/tmp/minicap-devel/minicap
  • '[' -e jni/minicap-shared/aosp/libs/android-6.0.1/arm64-v8a/minicap.so ']'
  • adb push jni/minicap-shared/aosp/libs/android-23/arm64-v8a/minicap.so /data/local/tmp/minicap-devel
    [100%] /data/local/tmp/minicap-devel/minicap.so
  • adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1024x600/0
    PID: 20256
    INFO: Using projection 1440x2560@338x600/0
    INFO: (external/MY_minicap/src/minicap_23.cpp:240) Creating SurfaceComposerClient
    INFO: (external/MY_minicap/src/minicap_23.cpp:243) Performing SurfaceComposerClient init check
    INFO: (external/MY_minicap/src/minicap_23.cpp:250) Creating virtual display
    INFO: (external/MY_minicap/src/minicap_23.cpp:256) Creating buffer queue
    INFO: (external/MY_minicap/src/minicap_23.cpp:261) Creating CPU consumer
    INFO: (external/MY_minicap/src/minicap_23.cpp:265) Creating frame waiter
    INFO: (external/MY_minicap/src/minicap_23.cpp:269) Publishing virtual display
    INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder
  • adb shell rm -r /data/local/tmp/minicap-devel

Why doesn't it work on emulators?

Read in the docs that it wouldn't work but went ahead and tried it on Genymotion, yeap doesn't work. But I'm curious what are the issues that cause it to fail? I'm willing to dive into making it work for emulators

Samsung Galaxy S5 Neo disconnects or seg faults.

phone:

manufacturer: 'SAMSUNG'
model: 'SM-G903F'
version: '5.1.1'
abi: 'armeabi-v7a'
sdk: '22'
product: 's5neoltexx'

When using STF, if the video stream is viewed it works for a few frames then the phone is disconnected. STF complains of lost connection to minicap.

When trying minicap by itself it hangs and segfaults. output below.

output of minicap:

INFO: Using projection 1080x1920@1080x1920/0
INFO: (external/MY_minicap/src/minicap_22.cpp:240) Creating SurfaceComposerClient
INFO: (external/MY_minicap/src/minicap_22.cpp:243) Performing SurfaceComposerClient init check
INFO: (external/MY_minicap/src/minicap_22.cpp:250) Creating virtual display
INFO: (external/MY_minicap/src/minicap_22.cpp:256) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_22.cpp:261) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_22.cpp:265) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_22.cpp:269) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 6268932 bytes for JPG encoder
INFO: (jni/minicap/minicap.cpp:444) New client connection
Segmentation fault

If no connection is made; the output of minicap stops and, even after waiting a considerable amount of time, no OK is printed.

We have also tested against Samsung S4 and Oneplus One. Both of these function flawlessly. So it is just the S5 Neo that is causing us issues.

Can i host on another android phone?

Hi,

Can i run node app.js on same android device ?
I am able to do run node on device but when i am running example/app.js on same device its giving error "adb forward tcp:1717 localabstract:minicap"

So my main issue is i cant do adb forward because i am running on same device,
So is this possible to get jpeg data on same device ?

Let me know for any more information Please help.

Thanks in advance

Regards,
Amit Garg

myself build, print two info: pid and info ... then auto exit

ago download from github execute and .so file,run is ok,today,myself download source code, then ndk-build,run minicap,print info:
PID: 17026
INFO: Using projection 1080x1920@1080x1920/0

them minicap is auto exit

use ps is not find pid of minicap

minicap_create is return NULL

very thanks for your help

checkout branch

The other branches are downloaded successfully, but the android-5.0.1_r1 is failed. The error info is:

[root@localhost /]# docker run -ti --rm -v /home/srv/aosp/mirror:/mirror -v /home/srv/aosp/android-5.0.1_r1:/aosp -v $PWD/.gitcookies:/root/.gitcookies:ro openstf/aosp:jdk7 /aosp.sh checkout-branch android-5.0.1_r1
Usage of loopback devices is strongly discouraged for production use. Either use --storage-opt dm.thinpooldev or use --storage-opt dm.no_warn_on_loop_devices=true to suppress this warning.
error: command 'sync' requires repo to be installed first.
Use "repo init" to install it here.

Vnc doesn't work with Samsung Galaxy Nexus I9250

I tried minicap with different phones starting from Android 2.3 until 6 but with this model it didn't work. I don't have any more 4.3 devices so I don't know if it's related to the Android version but with nexus it doesn't work. I really liked the work you did guys thou. It's cool

The error about building android 23 version

make: *** No rule to make target out/target/product/generic/obj/STATIC_LIBRARIES/libunwind_llvm_intermediates/export_includes', needed byout/target/product/generic/obj/SHARED_LIBRARIES/minicap_intermediates/import_includes'. Stop.

Local abstract

Hello,

Is it possible (with a rooted device) to forward the local abstract minicap to a tcp port from the device, like adb forward tcp:1717 localabstract:minicap, without using adb?

Thanks

Wrong frames in landscape mode

Hi!

I'm trying to use minicap with my Nexus 4 (api 22) and I have a problem with frames which I get when the device is rotated into a landscape mode.
I start minicap with the following command:
LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 768x1280@384x640/0

I consume the data with a client written in Java and it works beautifully in portrait mode.
As soon as I rotate the phone into a landscape I get this image:
minicap_rotated

In my Java client I'm just reading the frame and then decoding it from JPEG using ImageIO.
Is it a decoding issue or rotation is not supported yet?

Minicap error in my use

Minicap error in my use:
Cpu:arm64-v8a
Level:22
Using[adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0 -t]
Results show OK

But[adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0]
Display:

PID: 6706
INFO: Using projection 1080x1920@1080x1920/0
INFO: (external/MY_minicap/src/minicap_22.cpp:247) Creating SurfaceComposerClient
INFO: (external/MY_minicap/src/minicap_22.cpp:250) Performing SurfaceComposerClient init check
INFO: (external/MY_minicap/src/minicap_22.cpp:257) Creating virtual display
INFO: (external/MY_minicap/src/minicap_22.cpp:263) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_22.cpp:268) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_22.cpp:272) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_22.cpp:276) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 6268932 bytes for JPG encoder
INFO: (jni/minicap/minicap.cpp:585) ===E===

Black part in jpeg

Hi guys. I ran into an issue today. I ran the script with these arguments -P 1280x1920@640x960/0 on LG G2. The the global header said that it is 960 but then I got this image which was weird. I encountered this with my java client, then tried the example app and also got the same image. I don't get this when I project the real size of the phone. Any ideas?
screen shot 2015-12-20 at 21 21 52

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.