当前位置: 首页 > news >正文

adb 截屏和录屏命令

adb 录屏命令 screenrecord


简介

  1. screenrecord 是一个 shell 命令

  2. 支持 Android 4.4(API level 19)以上

  3. 支持视频格式: mp4

一些限制

某些设备可能无法直接录制,原因是分辨率太高,如果遇到此类问题,请试着指定较低的分辨率

不支持录制过程中屏幕旋转,如果录制过程中旋转,有可能画面被切断

录制视频的时候声音不会被录下来


### 开始录制命令:

adb shell screenrecord /sdcard/demo.mp4

说明:录制手机屏幕,视频格式为mp4,存放到手机sd卡里,默认录制时间为180s

限制录制时间:

参数: --time-limit

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

说明:限制视频录制时间为10s,如果不限制,默认180s

指定视频分辨率大小:

参数: --size

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

说明:录制视频,分辨率为1280*720,如果不指定默认使用手机的分辨率,为获得最佳效果,请使用设备上的高级视频编码(AVC)支持的大小

指定视频的比特率

参数: --bit-rate

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

说明:指定视频的比特率为6Mbps,如果不指定,默认为4Mbps. 你可以增加比特率以提高视频质量或为了让文件更小而降低比特率

[](https://blog.csdn.net/gdutxiaoxu/article/details/69802895

)在命令行显示log

参数: --verbose

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

输入以上命令,将可以看到这些信息。

Main display is 1080x1920 @59.16fps (orientation=0)

The max width/height supported by codec is 1920x1088

Configuring recorder for 1088x1920 video/avc at 4.00Mbps

Content area is 1080x1920 at offset x=4 y=0

Time limit 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

旋转90度

参数: --rotate

说明:此功能为实验性的,好不好用不知道

查看帮助命令

参数: --help

输入以下命令

adb shell screenrecord --help

将可以看到这些信息。

Usage: screenrecord [options]

Android screenrecord v1.2. Records the device’s display to a .mp4 file.

Options:

–size WIDTHxHEIGHT

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.

导出视频:

adb pull /sdcard/demo.mp4

说明:导出视频到当前目录

到处到指定的目录

adb pull /sdcard/demo.mp4 F:\mvp\demo.mp4


制作 gif 动图

利用 LICEcap 进行转换。


题外话


第一种方法,相对于第二种方法( 使用 adb 命令)来说,在截图和录制视频的时候,效率差不多,而在制作 gif 动图的时候,效率会快得挺多的,那为什么还要讲解 adb 命令呢?

一:让大家知道有更多的方法,开阔视野(哈哈,其实我是在扯蛋);

二:使用 Vysor 投影的时候,有一部分手机不支持,作为不是富二代的我们有时很无奈,不可能说为了能使用 Vysor 进行投影,而去重新买一部手机,这时候就退而求其次,使用 adb 命令了。

三: 作为一名开发人员,我们还是要学一些常用的命令的。这样也可以装装逼。

CSDN文章首发地址


推荐阅读


一步步拆解 LeakCanary

Android 面试必备 - http 与 https 协议

Android 面试必备 - 计算机网络基本知识(TCP,UDP,Http,https)

相关文章:

  • nginx安装教程
  • Python 学习 第四册 第8章 结构化的文本文件
  • 【LeetCode热题 100】三数之和
  • Python日志管理利器:如何高效管理平台日志
  • 【机器学习】智能创意工厂:机器学习驱动的AIGC,打造未来内容新生态
  • CentOS中的rename命令
  • 别让日志拖垮网站速度
  • Python多语言欧拉法和预测校正器实现
  • 20240621每日后端---------如何优化项目中的10000个if-else 语句?
  • ⭐Unity 控制任意UI的渐隐渐显
  • JDBC从入门到精通-笔记(一):JDBC基本概念与开发基础
  • 构建安全高效的前端权限控制系统
  • Flutter 实现软鼠标
  • 寻找重复数 - LeetCode 热题 100
  • QCombox绑定QMap
  • CoolViewPager:即刻刷新,自定义边缘效果颜色,双向自动循环,内置垂直切换效果,想要的都在这里...
  • HTML5新特性总结
  • MYSQL 的 IF 函数
  • node.js
  • nodejs实现webservice问题总结
  • Spark VS Hadoop:两大大数据分析系统深度解读
  • 给新手的新浪微博 SDK 集成教程【一】
  • 紧急通知:《观止-微软》请在经管柜购买!
  • 看图轻松理解数据结构与算法系列(基于数组的栈)
  • 如何实现 font-size 的响应式
  • 时间复杂度与空间复杂度分析
  • 数组大概知多少
  • Semaphore
  • 宾利慕尚创始人典藏版国内首秀,2025年前实现全系车型电动化 | 2019上海车展 ...
  • # windows 安装 mysql 显示 no packages found 解决方法
  • #pragma once
  • #每天一道面试题# 什么是MySQL的回表查询
  • #我与Java虚拟机的故事#连载16:打开Java世界大门的钥匙
  • $.proxy和$.extend
  • %3cli%3e连接html页面,html+canvas实现屏幕截取
  • (function(){})()的分步解析
  • (待修改)PyG安装步骤
  • (多级缓存)多级缓存
  • (黑马点评)二、短信登录功能实现
  • (转)一些感悟
  • (转载)Linux网络编程入门
  • .Net 6.0--通用帮助类--FileHelper
  • .Net Attribute详解(上)-Attribute本质以及一个简单示例
  • .NET CF命令行调试器MDbg入门(二) 设备模拟器
  • .NET 应用架构指导 V2 学习笔记(一) 软件架构的关键原则
  • .NET/C# 利用 Walterlv.WeakEvents 高性能地中转一个自定义的弱事件(可让任意 CLR 事件成为弱事件)
  • .NET/C# 中你可以在代码中写多个 Main 函数,然后按需要随时切换
  • .NET/C# 中设置当发生某个特定异常时进入断点(不借助 Visual Studio 的纯代码实现)
  • .net6 当连接用户的shell断掉后,dotnet会自动关闭,达不到长期运行的效果。.NET 进程守护
  • .NET企业级应用架构设计系列之应用服务器
  • .NET未来路在何方?
  • @Conditional注解详解
  • @EnableConfigurationProperties注解使用
  • @Value读取properties中文乱码解决方案
  • [ C++ ] STL_list 使用及其模拟实现