adbblitz


Nameadbblitz JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/adbblitz
SummaryADB - The fastest screenshots - scrcpy stream directly to NumPy (without scrcpy.exe) - no root required!
upload_time2023-05-22 03:01:37
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords port tcp usb adb screencap screenshots fast android
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ADB - Fastest screenshots - scrcpy raw stream directly to NumPy (without scrcpy.exe) - no root required!


### Tested against Windows 10 / Python 3.10 / Anaconda

### pip install adbblitz


### [with Google Pixel 6 - not rooted](https://github.com/hansalemaos/adbblitz/raw/main/google_pixel_6_2400x1080-no-root.mp4)


### [with Bluestacks 5 - not rooted ](https://github.com/hansalemaos/adbblitz/raw/main/adb_screenshot_test.mp4)



### TCP - Taking multiple screenshots 

If you want to take multiple screenshots using a TCP connection, you can use AdbShotTCP

Import the modules 

```python
from adbblitz import AdbShotUSB, AdbShotTCP
```

Use the with statement to create an instance of the AdbShotTCP class and specify the required parameters

Within the with block, you can iterate over the shosho object to capture screenshots
After everything is done, the socket connection will be closed, you don't have to take care about anything.


```python
from adbblitz import AdbShotUSB, AdbShotTCP
import numpy as np
from time import time
import cv2


with AdbShotTCP(
    device_serial="localhost:5555",
    adb_path=r"C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-win64-v2.0\adb.exe",
    ip="127.0.0.1",
    port=5555,
    max_frame_rate=60,
    max_video_width=960,
    scrcpy_server_version="2.0",
    forward_port=None,
    frame_buffer=24,
    byte_package_size=131072,
    sleep_after_exception=0.01,
    log_level="info",
    lock_video_orientation=0,
) as shosho:
framecounter = 0
stop_at_frame = None
fps = 0
start_time = time()
show_screenshot = True
# print(shosho)
for bi in shosho:
    if bi.dtype == np.uint16:
        continue
    cv2.imshow("title", bi)
    if cv2.waitKey(25) & 0xFF == ord("q"):
        # cv2.destroyAllWindows()
        # shosho.quit()
        break
    fps += 1
print(f"fast_ctypes_screenshots: {fps / (time() - start_time)}")
```


### TCP - Taking one screenshot at the time 

If you take only one screenshot, the connection will stay open until you call AdbShotTCP.quit()

```python
a = AdbShotTCP(
	device_serial="localhost:5555",
	adb_path=r"C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-win64-v2.0\adb.exe",
	ip="127.0.0.1",
	port=5037,
	sleep_after_exception=0.05,
	frame_buffer=4,
	lock_video_orientation=0,
	max_frame_rate=0,
	byte_package_size=131072,
	scrcpy_server_version="2.0",
	log_level="info",
	max_video_width=0,
	start_server=True,
	connect_to_device=True,
)

scr = a.get_one_screenshot()
scr.quit() # closes the connection
	
```

### USB - Taking multiple screenshots 

Same thing for USB 


```python

with AdbShotUSB(
    device_serial="xxxxx",
    adb_path=r"C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-win64-v2.0\adb.exe",
    adb_host_address="127.0.0.1",
    adb_host_port=5037,
    sleep_after_exception=0.05,
    frame_buffer=4,
    lock_video_orientation=0,
    max_frame_rate=0,
    byte_package_size=131072,
    scrcpy_server_version="2.0",
    log_level="info",
    max_video_width=0,
    start_server=True,
    connect_to_device=True,
) as self:
    start_time, fps = time(), 0
    for bi in self:
        if bi.dtype == np.uint16:
            continue
        cv2.imshow("test", bi)
        fps += 1
        if cv2.waitKey(25) & 0xFF == ord("q"):
            cv2.destroyAllWindows()
            break
    print(f"FPS: {fps / (time() - start_time)}")
    cv2.destroyAllWindows()
```

### USB - Taking one screenshot at the time 
```python

su=AdbShotUSB(
            device_serial="xxxxxx",
            adb_path=r"C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-win64-v2.0\adb.exe",
            adb_host_address="127.0.0.1",
            adb_host_port=5037,
            sleep_after_exception=0.05,
            frame_buffer=4,
            lock_video_orientation=0,
            max_frame_rate=0,
            byte_package_size=131072,
            scrcpy_server_version="2.0",
            log_level="info",
            max_video_width=0,
            start_server=True,
            connect_to_device=True,
        )
scr=su.get_one_screenshot()
scr.quit() # closes the connection

```
```

```






            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/adbblitz",
    "name": "adbblitz",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "port,tcp,usb,adb,screencap,screenshots,fast,Android",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5a/3e/92e0399fba5c6c75d5af6e8f4d103ac893918138acc4ce66ab89e5c38c8e/adbblitz-0.10.tar.gz",
    "platform": null,
    "description": "# ADB - Fastest screenshots - scrcpy raw stream directly to NumPy (without scrcpy.exe) - no root required!\r\n\r\n\r\n### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n### pip install adbblitz\r\n\r\n\r\n### [with Google Pixel 6 - not rooted](https://github.com/hansalemaos/adbblitz/raw/main/google_pixel_6_2400x1080-no-root.mp4)\r\n\r\n\r\n### [with Bluestacks 5 - not rooted ](https://github.com/hansalemaos/adbblitz/raw/main/adb_screenshot_test.mp4)\r\n\r\n\r\n\r\n### TCP - Taking multiple screenshots \r\n\r\nIf you want to take multiple screenshots using a TCP connection, you can use AdbShotTCP\r\n\r\nImport the modules \r\n\r\n```python\r\nfrom adbblitz import AdbShotUSB, AdbShotTCP\r\n```\r\n\r\nUse the with statement to create an instance of the AdbShotTCP class and specify the required parameters\r\n\r\nWithin the with block, you can iterate over the shosho object to capture screenshots\r\nAfter everything is done, the socket connection will be closed, you don't have to take care about anything.\r\n\r\n\r\n```python\r\nfrom adbblitz import AdbShotUSB, AdbShotTCP\r\nimport numpy as np\r\nfrom time import time\r\nimport cv2\r\n\r\n\r\nwith AdbShotTCP(\r\n    device_serial=\"localhost:5555\",\r\n    adb_path=r\"C:\\ProgramData\\chocolatey\\lib\\scrcpy\\tools\\scrcpy-win64-v2.0\\adb.exe\",\r\n    ip=\"127.0.0.1\",\r\n    port=5555,\r\n    max_frame_rate=60,\r\n    max_video_width=960,\r\n    scrcpy_server_version=\"2.0\",\r\n    forward_port=None,\r\n    frame_buffer=24,\r\n    byte_package_size=131072,\r\n    sleep_after_exception=0.01,\r\n    log_level=\"info\",\r\n    lock_video_orientation=0,\r\n) as shosho:\r\nframecounter = 0\r\nstop_at_frame = None\r\nfps = 0\r\nstart_time = time()\r\nshow_screenshot = True\r\n# print(shosho)\r\nfor bi in shosho:\r\n    if bi.dtype == np.uint16:\r\n        continue\r\n    cv2.imshow(\"title\", bi)\r\n    if cv2.waitKey(25) & 0xFF == ord(\"q\"):\r\n        # cv2.destroyAllWindows()\r\n        # shosho.quit()\r\n        break\r\n    fps += 1\r\nprint(f\"fast_ctypes_screenshots: {fps / (time() - start_time)}\")\r\n```\r\n\r\n\r\n### TCP - Taking one screenshot at the time \r\n\r\nIf you take only one screenshot, the connection will stay open until you call AdbShotTCP.quit()\r\n\r\n```python\r\na = AdbShotTCP(\r\n\tdevice_serial=\"localhost:5555\",\r\n\tadb_path=r\"C:\\ProgramData\\chocolatey\\lib\\scrcpy\\tools\\scrcpy-win64-v2.0\\adb.exe\",\r\n\tip=\"127.0.0.1\",\r\n\tport=5037,\r\n\tsleep_after_exception=0.05,\r\n\tframe_buffer=4,\r\n\tlock_video_orientation=0,\r\n\tmax_frame_rate=0,\r\n\tbyte_package_size=131072,\r\n\tscrcpy_server_version=\"2.0\",\r\n\tlog_level=\"info\",\r\n\tmax_video_width=0,\r\n\tstart_server=True,\r\n\tconnect_to_device=True,\r\n)\r\n\r\nscr = a.get_one_screenshot()\r\nscr.quit() # closes the connection\r\n\t\r\n```\r\n\r\n### USB - Taking multiple screenshots \r\n\r\nSame thing for USB \r\n\r\n\r\n```python\r\n\r\nwith AdbShotUSB(\r\n    device_serial=\"xxxxx\",\r\n    adb_path=r\"C:\\ProgramData\\chocolatey\\lib\\scrcpy\\tools\\scrcpy-win64-v2.0\\adb.exe\",\r\n    adb_host_address=\"127.0.0.1\",\r\n    adb_host_port=5037,\r\n    sleep_after_exception=0.05,\r\n    frame_buffer=4,\r\n    lock_video_orientation=0,\r\n    max_frame_rate=0,\r\n    byte_package_size=131072,\r\n    scrcpy_server_version=\"2.0\",\r\n    log_level=\"info\",\r\n    max_video_width=0,\r\n    start_server=True,\r\n    connect_to_device=True,\r\n) as self:\r\n    start_time, fps = time(), 0\r\n    for bi in self:\r\n        if bi.dtype == np.uint16:\r\n            continue\r\n        cv2.imshow(\"test\", bi)\r\n        fps += 1\r\n        if cv2.waitKey(25) & 0xFF == ord(\"q\"):\r\n            cv2.destroyAllWindows()\r\n            break\r\n    print(f\"FPS: {fps / (time() - start_time)}\")\r\n    cv2.destroyAllWindows()\r\n```\r\n\r\n### USB - Taking one screenshot at the time \r\n```python\r\n\r\nsu=AdbShotUSB(\r\n            device_serial=\"xxxxxx\",\r\n            adb_path=r\"C:\\ProgramData\\chocolatey\\lib\\scrcpy\\tools\\scrcpy-win64-v2.0\\adb.exe\",\r\n            adb_host_address=\"127.0.0.1\",\r\n            adb_host_port=5037,\r\n            sleep_after_exception=0.05,\r\n            frame_buffer=4,\r\n            lock_video_orientation=0,\r\n            max_frame_rate=0,\r\n            byte_package_size=131072,\r\n            scrcpy_server_version=\"2.0\",\r\n            log_level=\"info\",\r\n            max_video_width=0,\r\n            start_server=True,\r\n            connect_to_device=True,\r\n        )\r\nscr=su.get_one_screenshot()\r\nscr.quit() # closes the connection\r\n\r\n```\r\n```\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ADB - The fastest screenshots - scrcpy stream directly to NumPy (without scrcpy.exe) - no root required!",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/adbblitz"
    },
    "split_keywords": [
        "port",
        "tcp",
        "usb",
        "adb",
        "screencap",
        "screenshots",
        "fast",
        "android"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95d5d7fcbfcd6e485fe848f303942fc82af9991ab84d7b3fef1574f0523c4f8f",
                "md5": "fff7c06004f5386783ecc6073bd08efb",
                "sha256": "58135a0780cee4255ccd30efd65bab35bd2202b271a9be15d4ad50d90dbf9f85"
            },
            "downloads": -1,
            "filename": "adbblitz-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fff7c06004f5386783ecc6073bd08efb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 81069,
            "upload_time": "2023-05-22T03:01:35",
            "upload_time_iso_8601": "2023-05-22T03:01:35.414446Z",
            "url": "https://files.pythonhosted.org/packages/95/d5/d7fcbfcd6e485fe848f303942fc82af9991ab84d7b3fef1574f0523c4f8f/adbblitz-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a3e92e0399fba5c6c75d5af6e8f4d103ac893918138acc4ce66ab89e5c38c8e",
                "md5": "b8b6939f66299d38199f2b2c8f0c0141",
                "sha256": "b3dbdf5f4ff40c3e5375a451d8d6ad70bbd96d717eb517871627b3be5bc32b04"
            },
            "downloads": -1,
            "filename": "adbblitz-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "b8b6939f66299d38199f2b2c8f0c0141",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 83457,
            "upload_time": "2023-05-22T03:01:37",
            "upload_time_iso_8601": "2023-05-22T03:01:37.435580Z",
            "url": "https://files.pythonhosted.org/packages/5a/3e/92e0399fba5c6c75d5af6e8f4d103ac893918138acc4ce66ab89e5c38c8e/adbblitz-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-22 03:01:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "adbblitz",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "adbblitz"
}
        
Elapsed time: 0.15829s