preface

While blogging, we often need to take screenshots, record videos, or create GIFs. Today, we are going to talk about some of the methods of dependency.

The first method:

The screen of the phone is projected onto the computer, and software on the computer is used to take screenshots, record videos, or make GIFs.

Mobile phone screen sync is computer, we can use Vysor this Chrome plug-in, screenshot we can use QQ screenshot shortcut Ctrl + Alt + A, make GIF GIF we can use GIF conversion tool LICEcap

Download address

  • Sync your phone screen to your PC with Vysor, a Chrome plugin that you can download if you are interested

  • Easy to use GIF conversion tool LICEcap, official website address, download address

The second method:

Use the ADB command. Let’s take a look at how to use adb commands to take screenshots.


Adb screenshot command screencap

The first way

Adb shell /system/bin/screencap -p/SDCard /screenshot.png // Export from SD card to PC, note F:\\ MVP is the computer path, Must exist adb pull /sdcard/screenshot.png F:\\ MVP (save to computer)Copy the code

If you want to delete pictures on your phone, then you can use this command to delete them

adb shell rm /sdcard/screen.png
Copy the code

The second way

adb shell screencap -p | sed 's/\r$//' > screen.png
Copy the code

Note that the image will be saved in the current CMD startup path. Screen.png is the name of the image

If I run a command from C: Users\Administrator, it will be saved in the C: Users\Administrator directory.

C:\Users\Administrator>adb shell screencap -p | sed ‘s/\r$//’ > screen.png

extension

If you think that each time to enter such a long command adb shell screencap – p | sed ‘s / \ r $/ /’ > screen. The PNG, afraid to remember, we can adopt some methods. That’s an alias.

Since alias is a Linux-specific command, we can no longer use it on Windows. If you want to use a similar feature on Windows, please refer to the following blog.

The doskey command on Windows is similar to the alias command on Linux

Create Windows command line aliases


Adb Screenrecord command

Introduction to the

  1. Screenrecord is a shell command
  2. Support Android 4.4(API Level 19) or above
  3. Supported video format: MP4

Some restrictions

Some devices may not be able to record directly because the resolution is too high. If you encounter this problem, try to specify a lower resolution that does not support screen rotation during recording. If the screen rotation occurs during recording, the screen may be cut off and the voice will not be recorded during recording


## start recording command:

adb shell screenrecord /sdcard/demo.mp4
Copy the code

Recording mobile phone screen, video format mp4, stored in mobile SD card, the default recording time is 180s

Limited recording time:

Parameters: – time – limit

adb shell screenrecord  --time-limit 10 /sdcard/demo.mp4
Copy the code

Note: The video recording time is limited to 10s. If the video recording time is not limited, the default time is 180s

Specify video resolution size:

Parameters: – size

adb shell screenrecord --size 1280*720 /sdcard/demo.mp4
Copy the code

Note: Record video at a resolution of 1280*720. If you do not specify the resolution of your phone by default, use the size supported by the advanced Video Encoding (AVC) on your device for best results

Specifies the bit rate of the video

Parameters: – bit – rate

adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4
Copy the code

Note: The bitrate of the specified video is 6Mbps. If the bitrate is not specified, the default is 4Mbps. You can increase the bit rate to improve the video quality or decrease the bit rate to make the file smaller

Display log on the command line

Parameters: — verbose

adb shell screenrecord --time-limit 10 --verbose /sdcard/demo.mp4
Copy the code

Enter the above command and you will see this information.

Main display is 1080x1920 @59.16fps (orientation=0)
The max width/height supported by codec is 1920x1088
Configuring recorder for1088x1920 Video/AVC at 4.00Mbps Content Area is 1080x1920 at offset X =4 y=0 Time 1088x1920 video/ AVC at 4.00Mbps Content Area is 1080x1920 at offset X =4 y=0 Timelimit reached
Encoder stopping; recorded 133 frames in 10 seconds
Stopping encoder and muxer
Executing: /system/bin/am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sdcard/demo.mp4
Broadcasting: Intent { act=android.intent.action.MEDIA_SCANNER_SCAN_FILE dat=file:///sdcard/demo.mp4 }
Broadcast completed: result=0
Copy the code

Rotate 90 degrees

Parameters: – rotate

Note: this function is experimental, whether to use do not know

Viewing Help Commands

Parameters: — help

Enter the following command

adb shell screenrecord --help
Copy the code

You will be able to see this information.


Usage: screenrecord [options] <filename>

Android screenrecord v1.2.  Records the device's display to a .mp4 file. Options: --size WIDTHxHEIG Set the video size, e.g. "1280x720". Default is the device's main
    display resolution (if supported), 1280x720 if not.  For best results,
    use a size supported by the AVC encoder.
--bit-rate RATE
    Set the video bit rate, in bits per second.  Value may be specified as
    bits or megabits, e.g. '4000000' is equivalent to '4M'.  Default 4Mbps.
--bugreport
    Add additional information, such as a timestamp overlay, that is helpful
    in videos captured to illustrate bugs.
--time-limit TIME
    Set the maximum recording time, in seconds.  Default / maximum is 180.
--verbose
    Display interesting information on stdout.
--help
    Show this message.
    
Recording continues until Ctrl-C is hit or the time limit is reached.
Copy the code

Export video:

Adb pull /sdcard/demo.mp4 Note: Export the video to the current directory

Everywhere to the specified directory

adb pull /sdcard/demo.mp4 F:\mvp\demo.mp4
Copy the code

Make a GIF

LICEcap is used for conversion.


digression

The first method, compared to the second method (using ADB commands), is almost as efficient for capturing screenshots and recording videos, and much faster for creating GIFs, so why bother with ADB commands?

One: let people know that there are more ways to broaden their horizons (ha ha, actually I was lying);

Second: When using Vysor projection, some mobile phones do not support it. As people who are not rich second generation, we sometimes feel helpless. It is impossible to buy a new mobile phone in order to use Vysor projection.

Three: as a developer, we still need to learn some common commands. It’s also a good way to play pussy.

CSDN article launch address


Recommended reading

HTTP and HTTPS

Basic knowledge of computer networking (TCP, UDP, Http, HTTPS)

Android interview essentials – Threads

JVM and class loading mechanism

Android Interview prerequisites – System, App, Activity startup process

Interviewer Series – Do you really know HTTP

The interviewer asks, is HTTPS really secure, can you capture packets, and how to prevent packet capture

Android_interview making address

My CSDN blog: blog.csdn.net/gdutxiaoxu my nuggets: juejin. Cn/user / 220747… Making: github.com/gdutxiaoxu/ WeChat number: public Xu Gong code word (stormjun94) on zhihu: www.zhihu.com/people/xuju…

If you are interested, you can pay attention to my public account (Stormjun94), and I will update it in the first time