How to use the command 'scrcpy' (with examples)
Scrcpy is a command-line tool that allows users to display and control their Android device on their desktop. It provides a convenient way to mirror the Android device screen and even record the screen. With scrcpy, users can easily interact with their Android device using their computer’s keyboard and mouse.
Use case 1: Display a mirror of a connected device
Code:
scrcpy
Motivation:
This use case is useful when you want to view and control your connected Android device on your desktop. It allows you to easily interact with your Android apps, manage files, and perform other tasks using the convenience of your computer’s input devices.
Explanation:
The scrcpy
command alone without any arguments launches the scrcpy tool and displays a mirror of the connected Android device.
Example output:
A window will pop up displaying a real-time mirroring of the connected Android device’s screen on your desktop.
Use case 2: Display a mirror of a specific device based on its ID or IP address
Code:
scrcpy --serial 0123456789abcdef|192.168.0.1:5555
Motivation:
This use case is helpful when there are multiple devices connected, and you want to specifically mirror a particular device. By specifying the device ID or IP address, you can ensure that scrcpy mirrors the correct device.
Explanation:
The --serial
option allows you to specify the device ID of the Android device you wish to mirror. Alternatively, you can provide the IP address and port number of the device using the format IP_ADDRESS:PORT_NUMBER
.
Example output:
A window will appear, displaying a mirror of the desired Android device.
Use case 3: Start display in fullscreen mode
Code:
scrcpy --fullscreen
Motivation:
Running scrcpy in fullscreen mode maximizes the display area of the mirrored Android device on your desktop. This is particularly useful when you want to focus solely on the Android device’s screen without any distractions from other computer applications.
Explanation:
The --fullscreen
option instructs scrcpy to display the mirrored Android device in fullscreen mode.
Example output:
A window will open, showing the mirrored Android device screen in fullscreen mode.
Use case 4: Rotate the display screen
Code:
scrcpy --rotation 0|1|2|3
Motivation:
Sometimes it is necessary to rotate the display screen of the mirrored Android device. This use case allows users to adjust the display orientation to their preference.
Explanation:
The --rotation
option accepts values 0, 1, 2, or 3, representing 0, 90, 180, and 270 degrees counterclockwise rotations, respectively. By specifying the desired rotation value, scrcpy will adjust the display screen accordingly.
Example output:
The display screen of the mirrored Android device will rotate according to the specified value.
Use case 5: Show touches on physical device
Code:
scrcpy --show-touches
Motivation:
This use case is valuable for presentations or demonstrations where you want to display and highlight touch interactions on the mirrored Android device’s screen. It helps viewers understand the interactions performed on the physical device.
Explanation:
The --show-touches
option enables scrcpy to draw colored circles on the mirrored Android device’s screen, indicating touch events such as taps and swipes.
Example output:
As you perform touch interactions on the mirrored Android device’s screen, colored circles will appear to indicate the touch events.
Use case 6: Record display screen
Code:
scrcpy --record path/to/file.mp4
Motivation:
Recording the display screen of the mirrored Android device is useful for creating video tutorials, documenting app workflows, or capturing specific moments for later analysis or sharing.
Explanation:
The --record
option instructs scrcpy to record the mirrored Android device’s screen. The argument following the option should be the path and filename of the output file, specifying the format as .mp4
.
Example output:
Scrcpy will start recording the display screen and save it as a video file at the specified path and filename.
Use case 7: Set target directory for pushing files to device by drag and drop (non-APK)
Code:
scrcpy --push-target path/to/directory
Motivation:
This use case allows users to easily transfer files from their desktop to the connected Android device using drag and drop functionality. By specifying the target directory, you can conveniently copy files to a specific location on the Android device.
Explanation:
The --push-target
option sets the target directory on the connected Android device where files dragged and dropped onto the scrcpy window will be copied.
Example output:
When files are dragged and dropped onto the scrcpy window, they will be copied to the specified directory on the connected Android device.