Appearance
adb screenshot and screenrecord: capture the phone's screen
In short: To take an adb screenshot, run adb exec-out screencap -p > screen.png, which saves the phone's screen as a PNG on your computer. To record the screen, run adb shell screenrecord /sdcard/demo.mp4, stop it with Ctrl+C or after at most 180 seconds, and copy the video over with adb pull. Neither needs root.
Screenshots and recordings from adb are the quickest way to attach evidence to a bug report without picking up the phone.
Take a screenshot
bash
adb exec-out screencap -p > screen.pngpowershell
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.pngexec-out streams the PNG straight into the file on your computer. Windows PowerShell 5.1, the version built into Windows, changes binary output sent to a file with >, which breaks the PNG, so on Windows the picture is saved on the phone, copied over and then deleted from the phone.
Record the screen
bash
adb shell screenrecord --time-limit 30 /sdcard/demo.mp4
adb pull /sdcard/demo.mp4
adb shell rm /sdcard/demo.mp4| Option | What it does |
|---|---|
--time-limit 30 | Stops after 30 seconds; the default and the maximum are 180 |
--size 1280x720 | Records at a smaller size, which also helps when the encoder fails at full resolution |
--bit-rate 4M | Sets the video's bit rate; higher is sharper and larger |
--bugreport | Adds the time and other details to the video, useful in bug reports |
Press Ctrl+C to stop a recording early. The video has no sound, and parts of the screen that apps mark as secure are black.
Why is my Android screenshot black?
A black or partly black picture has one of four causes. Each has a command to check it; the commands run the same in bash and PowerShell because the filtering happens on the phone.
1. The app marks its window as secure
Apps can set Android's FLAG_SECURE on a window. Google's documentation describes it as treating the window's content as secure, keeping it out of screenshots and off non-secure displays. Banking, payment and password apps often set it. Android then leaves that window out of screencap, screenrecord and every screen-sharing tool, so the picture is black where the app is.
Check which window is in front and whether any window has the flag:
bash
adb shell "dumpsys window | grep -E 'mCurrentFocus|SECURE'"mCurrentFocus names the app and screen in front. A window's flags are listed after fl=, and SECURE among them means that window is protected. Nothing on the computer changes this: test that screen by hand, or, for your own app, leave the flag off in debug builds.
2. The video is protected
Video players that use DRM-protected playback usually draw the video on a protected surface, which captures show as a black rectangle while the rest of the screen appears. Pause on a screen without the video to capture it, or test the player by hand.
3. The screen is off or asleep
A phone whose screen is off captures as black. Check the power state, then wake it:
bash
adb shell "dumpsys power | grep mWakefulness="
adb shell input keyevent KEYCODE_WAKEUPmWakefulness=Awake means the screen is on; Asleep or Dozing means it is not. A locked phone captures the lock screen rather than your app, so unlock it first.
4. You captured a different display
Foldables with an outer screen, and phones with a connected display, have more than one display, and screencap captures one of them. List the displays and capture the one you want:
bash
adb shell dumpsys SurfaceFlinger --display-id
adb exec-out screencap -p -d DISPLAY_ID > screen.pngReplace DISPLAY_ID with a number from the first command. On recent Android versions screencap -a captures every active display into numbered files.
scrcpy, Android Studio and BenchFleet capture the screen through the same Android interfaces, so a secure window is black in them too. When a step of a BenchFleet workflow lands on such a screen, its screenshot in the run's replay is black and the step's other evidence, such as the UI tree, still shows what was there.
On many phones at once
Comparing the same screen on many phones is how layout bugs show up. Save each phone's screenshot under its own name:
bash
for s in $(adb devices | awk 'NR>1 && $2=="device" {print $1}'); do
adb -s "$s" exec-out screencap -p > "screen-${s//[:\/]/_}.png"
donepowershell
adb devices | Select-Object -Skip 1 | ForEach-Object {
$serial, $state = $_ -split '\s+'
if ($state -eq 'device') {
adb -s $serial shell screencap -p /sdcard/screen.png
adb -s $serial pull /sdcard/screen.png "screen-$($serial -replace '[:\\/]', '_').png"
}
}BenchFleet shows every connected phone's screen live on one page. On Pro, its group actions take screenshots on many phones at once, and each workflow run keeps a screenshot of every step, so a failed run can be replayed step by step.
On our 17 test phones a screenshot took a median of 297 ms one phone at a time and 401 ms with all 17 at once (the measurements). Android app testing on real devices shows how those replays help when a test fails on one phone.
Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from $16 a month + VAT (including 300 cloud phone minutes every month).
Common errors and fixes
| Problem | What it means | Fix |
|---|---|---|
| The screenshot is black | A secure window, protected video, a sleeping screen or another display | See why screenshots are black |
| The PNG will not open on Windows | PowerShell changed the binary output | Use the save-and-pull commands above |
Encoder failed or a recording that stops at once | The phone cannot encode video at full resolution | Add --size 1280x720 |
| The recording stops after three minutes | screenrecord's limit is 180 seconds | Start a new recording, or use scrcpy's recording |
adb: more than one device/emulator | Several phones are connected | Choose one with -s and its serial number |
Related
- adb push and pull: copy screenshots and recordings from the phone.
- adb logcat: the log to go with the screenshot.
- scrcpy for many phones: mirror and record phone screens on your computer.
- ADB over Wi-Fi: take screenshots of a phone that is not plugged in.
- Google's Android Debug Bridge guide documents
screencapandscreenrecord. - All ADB commands and the ADB command builder.
Questions
How do I take a screenshot with adb?
In bash or zsh, run adb exec-out screencap -p > screen.png. In Windows PowerShell, save it on the phone with adb shell screencap -p /sdcard/screen.png and copy it with adb pull /sdcard/screen.png.
How do I record the screen with adb?
Run adb shell screenrecord /sdcard/demo.mp4, stop it with Ctrl+C or let it reach its time limit, then run adb pull /sdcard/demo.mp4 to copy the video to your computer.
How long can adb screenrecord record?
180 seconds at most, which is also the default; --time-limit sets a shorter limit. For longer recordings, start a new one when the last ends, or record with scrcpy, which has no such limit.
Where is the adb screenshot saved, and how do I choose its name?
With adb exec-out screencap -p > screen.png, the PNG file lands in the folder your terminal is in, under the name after the >, so give a full path or another name there. With adb shell screencap, it is saved on the phone at the path you give, such as /sdcard/screen.png, until you copy it with adb pull.
Why is my Android screenshot black?
Usually because the app on screen marks its window as secure, as banking and payment apps do, so Android leaves it out of screenshots and recordings. Protected video, a screen that is off, and capturing the wrong display give black pictures too. The section on black screenshots shows a command to check each one.
Can adb record sound?
No, screenrecord captures video only. scrcpy can record the screen with sound on Android 11 and newer.
Start with the Free plan
Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from $16 a month + VAT (including 300 cloud phone minutes every month).
- A Free plan with no time limit and no account
- Starts in Local mode, with no telemetry or analytics in the app