Mirror Your Android Screen on Linux With This Free Tool


Mirror Your Android Screen on Linux With This Free Tool

Quick Links What Is scrcpy? Installing scrcpy on Linux Mirroring Android on Linux via USB Wirelessly Mirroring Android on Linux Here's What Else You Can Do With scrcpy

Looking for a way to easily mirror your Android phone's screen on your Linux desktop? I've found a tool that lets you do so. The best part? It's free and there's no string attached. It's called scrcpy. Let's explore it and see its potential in this guide.

What Is scrcpy?

scrcpy (pronounced "screen copy") is a lightweight, open-source tool that allows you to mirror and control your Android device directly from your computer. It supports Windows, macOS, and Linux, but is especially popular among Linux users for its simplicity and versatility. scrcpy uses the Android Debug Bridge (ADB) to establish a connection between your Android device and your computer.

The tool makes use of Android's screen-casting capabilities to encode your device's screen into an H.264 video stream. This stream is sent to your computer via USB (or Wi-Fi for advanced setups). A cool thing is that scrcpy forwards keyboard and mouse inputs from your computer to your Android device, allowing you to interact with the mirrored screen seamlessly. Despite being lightweight, scrcpy is highly efficient, offering low latency, high frame rates, and support for 1920x1080 resolution or higher.

Installing scrcpy on Linux

For demonstration, I'm using Ubuntu 24.04 LTS. However, I'll share instructions for other Linux distros where applicable. First, you need to install scrcpy on Linux.

If you're using Arch Linux or a derivative of Arch, install it from your package manager with this command:

pacman -S scrcpy

Fedora users should use this command:

dnf copr enable zeno/scrcpy && dnf install scrcpy

On Gentoo Linux, use:

emerge scrcpy

If you're using Debian, Ubuntu, or their derivatives, you can install it using snap:

snap install scrcpy Getting scrcpy on Debian/Ubuntu Without snap

If you don't want to use snap on a Debian or Ubuntu-based system, be aware it's not recommended to use the official APT package to install scrcpy because the package is too old. Instead, you can use the provided installation script. First, update your system:

sudo apt update

Then, install these dependencies:

sudo apt install ffmpeg libsdl2-2.0-0 adb wget \

gcc git pkg-config meson ninja-build libsdl2-dev \

libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \

libswresample-dev libusb-1.0-0 libusb-1.0-0-dev

After that, clone their GitHub repo and run the installation script:

git clone https://github.com/Genymobile/scrcpy

cd scrcpy

./install_release.sh

Once you've successfully installed it, check the version by running:

scrcpy --version

This confirms that our installation was successful. If you need to update scrcpy whenever there's a new release, pull the content from the GitHub repository again and run the installation script:

git pull

./install_release.sh Mirroring Android on Linux via USB

First, connect your Android phone to your Linux device with a USB cable. Make sure to enable USB debugging on Android if you haven't already.

If you're running Linux on your bare device, your phone should connect to your desktop immediately. However, if you're running a virtual machine, then you need to enable the device from the USB menu. On VirtualBox, go to Devices > USB. Tick the box for your phone name.

To confirm the connection, run this adb command in your terminal:

adb devices

We've attached the device successfully. To mirror your Android screen on your Linux device, run:

scrcpy

You can use your mouse to control the Android phone. Click on an app to open it or scroll to change the window. The mouse right-click button works as the back button. The middle-click button acts as the home button. There are many other useful shortcuts that allow you to have better control using your mouse and keyboard.

If you have multiple devices connected to your Linux device at the same time, you can specify which one to mirror in four ways:

1. Passing the phone's serial number as an argument. You can find the serial number in the device settings.

scrcpy --serial=example_serial_number

2. Mirroring the phone connected via USB (works when there's only one device connected via cable)

scrcpy --select-usb

3. Mirroring the phone connected over TCP/IP (works when there's only one device connected in this method)

scrcpy --select-tcpip

4. Passing the phone's IP address as an argument if it's listening on TCP/IP

scrcpy --tcpip=192.168.1.1:5555 Wirelessly Mirroring Android on Linux

If you don't want to get into cable troubles, you can also set up scrcpy to mirror your Android phone's screen wirelessly. For this, both devices need to be on the same Wi-Fi network. First, connect your phone to the Linux desktop via a USB cable. Make sure it's recognized by adb:

adb devices

Then enable wireless debugging on your phone by running this command:

adb tcpip 5555

Now disconnect the phone from the USB cable. Find the IP address of your phone. You can find it in the phone Settings or Wi-Fi settings. I'm using a Samsung device, so in my case, I had to go to Settings > About Phone > Status information to find the IP address.

Once you find the IP address, run this command in the terminal:

adb connect ip.address.of.phone:5555

If all seems well, run scrcpy to mirror the Android screen wirelessly:

scrcpy

You should see your phone's screen on your desktop even though it's not connected via USB. Depending on your internet connection, you may notice a performance drop or more latency in the wireless connection than the wire connection. I personally prefer wireless mirroring since I don't have to deal with cables.

Here's What Else You Can Do With scrcpy

scrcpy is much more than just an Android screen mirroring tool. You can record your Android screen, use the phone camera, play audio on the desktop, and control how you can interact with your Android phone via scrcpy. Let's quickly go through some features you might find interesting.

You can change some of the settings of the video stream that you're forwarding from your Android phone, such as screen size, bit rate, codec, and frame rate.

scrcpy --max-size=1024 # The width is calculated from your device's aspect ratio

scrcpy --video-bit-rate=2000000

scrcpy --max-fps=15

scrcpy --video-codec=h265

If you want to mirror your phone's camera instead of the screen, run:

scrcpy --video-source=camera

As for audio, if you're mirroring the display, by default, your phone's output audio will be played on the desktop. If you're mirroring the camera, then your phone's microphone audio will be played on the desktop. You can choose which audio source to use or disable it completely.

scrcpy --audio-source=mic # or --audio-source=output

scrcpy --video-source=camera --no-audio # audio isn't forwarded

If you want to record the video and audio being mirrored, run:

scrcpy --record=file.mp4

scrcpy --no-audio --record=file.mp4 # to only record the video

scrcpy --no-video --audio-codec=raw --record=file.wav # to only record the audio

Another feature that grabbed my attention is the virtual display. Basically, you can create more displays and mirror them on the desktop, not necessarily mirroring your phone screen. For example, you can have one display mirroring the phone screen while another display, a virtual display, shows an app. If, for example, you'd like to run VLC in a virtual display, run:

scrcpy --new-display=1920x1080 --start-app=org.videolan.vlc

Likewise, you can start as many new virtual displays as you wish.

There are many screen mirroring tools available for Android. However, scrcpy being free and open-source and containing many powerful features make it a top contender. If you want to learn more about this tool, run man scrcpy on your terminal or visit the official documentation.

Previous articleNext article

POPULAR CATEGORY

corporate

10091

tech

11359

entertainment

12383

research

5613

misc

13113

wellness

9974

athletics

13102