Package: adbnativeblitz
ADB Screenshots as fast as scrcpy, but 100% native!Tested against Windows / Python 3.11 / Anacondapip install adbnativeblitzAdbFastScreenshots offers a powerful and efficient way to capture
Android device screens, making it a valuable tool
for a wide range of applications and use cases.
As fast ashttps://github.com/hansalemaos/adbblitz, but 100% native!Advantages:High Frame Rate:AdbFastScreenshots is designed to capture the Android device's screen
with an improved frame rate, which can be especially useful for applications
that require real-time or high-speed screen recording,
such as gaming or performance analysis.Efficiency:By avoiding the overhead of creating a new subprocess for each screen
capture session, it is more efficient and less
resource-intensive than traditional methods,
making it suitable for continuous screen capture.Ease of Use:It provides a Pythonic interface for screen capturing,
making it easier for developers to integrate Android
screen recording into their applications.Control and Flexibility:It allows users to control the screen recording process,
including starting and stopping capture,
making it suitable for custom applications that
require precise control.Context Manager:Designed to be used as a context manager,
it ensures proper resource cleanup and termination,
which is important in long-running applications.Example with Bluestacks:https://www.youtube.com/watch?v=Sw-F1sobIlYCaptureAndroiddevicescreenusingADB's screenrecord with high frame rate.ThisclassallowscapturingthescreenofanAndroiddeviceusingADB's screenrecordcommandwithanimprovedframerate.ItcontinuouslycapturesframesfromthedeviceandprovidesthemasNumPyarraystothecaller.Args:adb_path(str):ThepathtotheADBexecutable.device_serial(str):TheserialnumberofthetargetAndroiddevice.time_interval(int):Themaximumduration,inseconds,foreachscreenrecordingsession(uptoamaximumof180seconds).Afterreachingthistimelimit,anewrecordingsessionautomaticallystartswithoutcausinginterruptionstotheuserexperience.width(int):Thewidthofthecapturedscreen.height(int):Theheightofthecapturedscreen.bitrate(str):Thebitrateforscreenrecording(e.g.,"20M"for20Mbps).use_busybox(bool):WhethertouseBusyBoxforbase64encoding.connect_to_device(bool):WhethertoconnecttothedeviceusingADB.screenshotbuffer(int):Thesizeoftheframebuffertostorethelastcapturedframes.go_idle(float):Theidletime(inseconds)whennonewframesareavailable.# higher value -> less fps, but also less CPU usage.Attributes:stop_recording(bool):Controlattributetostopthescreencapture.Methods:stop_capture():Stopsthescreencapture.Usage:importcv2fromadbnativeblitzimportAdbFastScreenshotswithAdbFastScreenshots(adb_path=r"C:\Android\android-sdk\platform-tools\adb.exe",device_serial="127.0.0.1:5555",time_interval=179,width=1600,height=900,bitrate="20M",use_busybox=False,connect_to_device=True,screenshotbuffer=10,go_idle=0,)asadbscreen:forimageinadbscreen:cv2.imshow("CV2 WINDOW",image)ifcv2.waitKey(1)&0xFF==ord("q"):breakcv2.destroyAllWindows()Note:-The`AdbFastScreenshots`classshouldbeusedinacontextmanager(`with`statement).-The`stop_capture()`methodcanbecalledtostopthescreencapture.-TheframesarecontinuouslycapturedandprovidedintheformofNumPyarrays.-Theclassaimstoachieveahigherframeratebyavoidingslowsubprocesscreationforeachscreencapturesession.