[新服务] scrcpy 2 to show android phone on mac/windows/etc

date
Apr 2, 2023
slug
newservice-scrspy-android-cast
status
Published
summary
新服务 关键是手机和电脑都可以控制手机
tags
service
type
Post

Summary

步骤

安卓手机开启USB Debugging - 用Vivo 手机举例

notion image

华为手机的特殊方式来打开

  • 软件版本这 点击7-10次,出现“您正处于开发者模式!”
  • “仅充电”应该可以不用打开
notion image
notion image

电脑端 - Mac

brew install scrcpy
# this will install adb tools
brew install --cask android-platform-tools

# 这之后,只要手机(开启USB Debugging功能之后)用线连上,即可用adb 来链接

# 开启无线连接
# 先有线连上
adb devices
adb tcpip 5555 # 这是只有一台设备的时候, 开启所连接手机的5555端口用于adb connection
# 如有多台, 则
adb –s <device_ID> tcpip 5555

# 获得安卓手机的IP之后(要在同一个网络)
# adb connect DEVICE_IP:5555 # (replace DEVICE_IP)
(有线则不需要这一步,或者 adb connect <device_ID>)
adb connect 10.13.2.233:5555

# To switch back to USB mode: 
# adb usb



# 启动
scrcpy
scrcpy --always-on-top
scrcpy --always-on-top --display-buffer=250 --audio-buffer=250

scrcpy --record=vivi10_$(date +%Y%m%d_%H%M).mp4
scrcpy --no-audio --record=vivo10_$(date +%Y%m%d_%H%M).mp4



#The default buffer size is set to 50ms. It can be adjusted:
scrcpy --audio-buffer=40   # smaller than default
scrcpy --audio-buffer=100  # higher than default
# If you don't interact with the device (to watch a video for example), a higher latency (for both video and audio) might be preferable to avoid glitches and smooth the playback:
scrcpy --display-buffer=250 --audio-buffer=250
notion image
notion image
notion image
notion image
notion image
notion image
 

常用快捷键

  • 切换全屏模式 Ctrl+f
  • 点击手机电源 Ctrl+p
  • 返回 Ctrl+b
  • 返回到HOME Ctrl+h
  • 多任务 Ctrl+s
  • 更多操作 长按鼠标左键
  • 显示最佳窗口 Ctrl+g
  • 调节音量 Ctrl+上下键
  • 关闭设备屏幕(保持镜像) Ctrl+o
  • 将设备剪贴板复制到计算机 Ctrl+c
  • 将计算机剪贴板粘贴到设备 Ctrl+v

vivo手机无法转发audio到电脑

解决方法 - mac上换临时修改的scr-server.zip from j

# unzip scrcpy-server.zip
cd /opt/homebrew/Cellar/scrcpy/2.0/share/scrcpy; mv scrcpy-server scrcpy-server.bak

# unzipped
mv /PATH/TO/UNZIPPED/scrcpy-server /opt/homebrew/Cellar/scrcpy/2.0/share/scrcpy/

scrcpy --require-audio

# uncompressed
# scrcpy --audio-codec=aac 
notion image

© Ying Bun 2021 - 2024