求指导!同屏协作,安卓手机桌面实时回传电脑,已经使用Python已经获取到Android手机的桌面视频流,求转成图片流或者其他能显示到桌面的方式。
import subprocess
import socket
import time
import numpy as np
adb_path = "D:\\scrcpy-win64-v1.24\\adb" //自己的adb位置
port=15555 //随便设置的端口号
device_uuid="自己设备" //自己设备
scrcpy_server_path = "scrcpy-server"
p = subprocess.Popen(f"{adb_path} -s {device_uuid} push {scrcpy_server_path} /data/local/tmp", shell=True)
p.communicate()
p = subprocess.Popen(f"{adb_path} -s {device_uuid} forward tcp:{port} localabstract:scrcpy", shell=True)
p.communicate()
p = subprocess.Popen(f"{adb_path} -s {device_uuid} shell CLASSPATH=/data/local/tmp/scrcpy-server app_process / com.genymobile.scrcpy.Server 1.24 max_size=1000 log_level=info bit_rate=8000000 tunnel_forward=true", shell=True)
time.sleep(1)
s1 = socket.socket()
s1.connect(("127.0.0.1", port))
temp = s1.recv(1024)
while temp != b'\x00':
temp = s1.recv(1024)
print("connected: " + str(temp))
s2 = socket.socket()
s2.connect(("127.0.0.1", port))
info_raw = s1.recv(64)
info = info_raw.decode(encoding="utf-8")
width_raw = s1.recv(2)
height_raw = s1.recv(2)
print(info)
width = int.from_bytes(width_raw, byteorder='big')
height = int.from_bytes(height_raw, byteorder='big')
print(width)
print(height)
while True:
data = s1.recv(1024)
print(data)
运行处的视频h246裸流如下,想把它转为图片流或者能直接显示在窗体是更好了。
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/647379035756169.png?x-oss-process=image/auto-orient,1/resize,w_320,m_lfit)
想尝试使用ffmpeg处理h246的方式,但是只有通过c语言的房处理,在考虑是否将获取到的h246视频流传入c语言中处理。
最终效果想要可以达到类似于这种同屏幕协作。
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/990424135756139.png?x-oss-process=image/auto-orient,1/resize,w_320,m_lfit)