Giter Site home page Giter Site logo

pyscrcpy's Introduction

Python Scrcpy Client

Introduction

scrcpy-badge

A Python Library for scrcpy
pyscrcpy is an innovative Python library designed to simplify and streamline the integration of scrcpy into your Python projects. Scrcpy, a versatile screen mirroring tool for Android devices, gains a new level of accessibility through the seamless capabilities provided by pyscrcpy.

Key Features

  1. Easy Integration: With pyscrcpy, incorporating scrcpy functionality into your Python scripts becomes a straightforward process. The library abstracts away the complexities, allowing you to focus on leveraging scrcpy's powerful features without the need for intricate setup.
  2. Enhanced Control: pyscrcpy empowers developers to exert precise control over Android devices from within their Python applications. Whether it's automating UI interactions, conducting tests, or creating custom applications, pyscrcpy provides a convenient interface for managing scrcpy commands.
  3. Customization Options: Tailor scrcpy behavior to suit your project's requirements using the customizable options provided by pyscrcpy. Fine-tune parameters such as display size, bit rate, and more, all while maintaining the simplicity of Python scripting.

Demo & Tutorial

import cv2 as cv
from pyscrcpy import Client # import scrcpy client


def on_frame(client, frame):
    client.control.touch(300,500)# emulate touch on(300,500)
    cv.imshow('Video', frame)
    cv.waitKey(1)


def demo1():
    client = Client(max_fps=1, max_size=900)
    client.on_frame(on_frame)
    client.start()

def demo2():
    client = Client(max_fps=20)
    client.start(threaded=True)  # create a new thread for scrcpy
    while 1:
        if client.last_frame is None:
            continue
        on_frame(client, client.last_frame)

Reference & Appreciation

pyscrcpy's People

Contributors

leng-yue avatar s1m0n38 avatar yixinnb avatar

Stargazers

 avatar  avatar aurora avatar xiaozai avatar  avatar  avatar

Watchers

 avatar

pyscrcpy's Issues

Issue when insalling the package

I use Python 3.12.3

C:\Windows\system32>pip install pyscrcpy
Collecting pyscrcpy
Using cached pyscrcpy-1.0.1-py3-none-any.whl.metadata (3.3 kB)
Collecting adbutils<2.0.0,>=1.0.8 (from pyscrcpy)
Using cached adbutils-1.2.15-py3-none-win_amd64.whl.metadata (915 bytes)
Collecting av<11.0.0,>=9.0.0 (from pyscrcpy)
Using cached av-10.0.0.tar.gz (2.4 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [74 lines of output]
Compiling av\buffer.pyx because it changed.
[1/1] Cythonizing av\buffer.pyx
Compiling av\bytesource.pyx because it changed.
[1/1] Cythonizing av\bytesource.pyx
Compiling av\descriptor.pyx because it changed.
[1/1] Cythonizing av\descriptor.pyx
Compiling av\dictionary.pyx because it changed.
[1/1] Cythonizing av\dictionary.pyx
Compiling av\enum.pyx because it changed.
[1/1] Cythonizing av\enum.pyx
Compiling av\error.pyx because it changed.
[1/1] Cythonizing av\error.pyx
Compiling av\format.pyx because it changed.
[1/1] Cythonizing av\format.pyx
Compiling av\frame.pyx because it changed.
[1/1] Cythonizing av\frame.pyx
performance hint: av\logging.pyx:232:5: Exception check on 'log_callback' will always require the GIL to be acquired.
Possible solutions:
1. Declare 'log_callback' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
2. Use an 'int' return type on 'log_callback' to allow an error code to be returned.

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  cdef const char *log_context_name(void *ptr) nogil:
      cdef log_context *obj = <log_context*>ptr
      return obj.name

  cdef lib.AVClass log_class
  log_class.item_name = log_context_name
                        ^
  ------------------------------------------------------------

  av\logging.pyx:216:22: Cannot assign type 'const char *(void *) except? NULL nogil' to 'const char *(*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to the type of 'log_context_name'.

  Error compiling Cython file:
  ------------------------------------------------------------
  ...

  # Start the magic!
  # We allow the user to fully disable the logging system as it will not play
  # nicely with subinterpreters due to FFmpeg-created threads.
  if os.environ.get('PYAV_LOGGING') != 'off':
      lib.av_log_set_callback(log_callback)
                              ^
  ------------------------------------------------------------

  av\logging.pyx:351:28: Cannot assign type 'void (void *, int, const char *, va_list) except * nogil' to 'av_log_callback' (alias of 'void (*)(void *, int, const char *, va_list) noexcept nogil'). Exception values are incompatible. Suggest adding 'noexcept' to the type of 'log_callback'.
  Compiling av\logging.pyx because it changed.
  [1/1] Cythonizing av\logging.pyx
  Traceback (most recent call last):
    File "C:\Users\DK\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
    File "C:\Users\DK\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\DK\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\DK\AppData\Local\Temp\pip-build-env-bjct2imz\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\DK\AppData\Local\Temp\pip-build-env-bjct2imz\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
      self.run_setup()
    File "C:\Users\DK\AppData\Local\Temp\pip-build-env-bjct2imz\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
      super().run_setup(setup_script=setup_script)
    File "C:\Users\DK\AppData\Local\Temp\pip-build-env-bjct2imz\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 157, in <module>
    File "C:\Users\DK\AppData\Local\Temp\pip-build-env-bjct2imz\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
    File "C:\Users\DK\AppData\Local\Temp\pip-build-env-bjct2imz\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: av\logging.pyx
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

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.