woensdag 16 januari 2019

Mirror Android Phone on Linux

Getting you Android phone connected to a Linux box is not so difficult; install and run adb (android developers bridge) to swap files. Mirroring and controlling the device is a bit more difficult. Using scrcpy makes it possible.
How does that work? scrcpy installs a server on your phone and communicates with the Linux box over adb. This server sends a video stream to the  Linux box; all input (mouse and keyboard) events are captured, which makes interaction with the phone easy.
For installing scrcpy there are to possibilities:
- build the app manually;
- run a docker image


For me the last option is the easiest. I have adb installed and I have docker running.
For installing docker and controlling docker images with Portainer see: https://d3-media.blogspot.com/2018/08/portainer.html 
Download or clone the image  from Github and follow the instruction:

- give docker acces to the x-server:
xhost + local:docker
- check inside the container if there is a connection to the android device:
adb devices
- run the docker image with one of the following option: amd, intel, nvidia:
docker run --rm -i -t --privileged \
    -v /dev/bus/usb:/dev/bus/usb \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    pierlo1/scrcpy:<graphics type>
- finally run scrcpy with options:
 scrcpy [options]
There are options for size, bit rate, crop, record screen, bu starting default works perfect. Once the app is running there various short cuts to control the device, look at the readme.
Run for example:
scrcpy --record file.mp4
Here is the video:



Geen opmerkingen:

Een reactie posten

Opmerking: Alleen leden van deze blog kunnen een reactie posten.