- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
如何从 Java
在 Android
设备上运行 adb shell screenrecord
并结束 screenrecording
?
目前我必须指定--time-limit
来结束录制。如果我尝试在视频结束前捕捉视频,则会失败。
有没有办法告诉 adb 停止记录?有没有办法配置线程向 shell
命令发送 CTRL-C
?
这将在无根电话上运行。
代码
videoExecutor.submit(() -> {
//Start recording video
String recordVideo = "screenrecord --time-limit " + testRun.getVideoLength() + " " + "/sdcard/" + logDate + ".mp4";
try {
device.executeShell(recordVideo);
} catch (Exception e1) {
e1.printStackTrace();
}
sleep(testRun.getVideoLength()*ONE_SECOND + TWO_SECONDS); //gotta match the --time-limit above.
RemoteFile remote = new RemoteFile("/sdcard/" + logDate + ".mp4");
File local = new File(videoPath); //Save file to local machine
if(!local.getParentFile().exists()) {
local.getParentFile().mkdirs();
}
try {
//Copy video from phone to computer
try {
device.pull(remote, local);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
最佳答案
发送 SIGINT
或 SIGHUP
到 screenrecord
进程会导致它停止记录。
我刚刚在 2 个单独的 adb shell
session 中尝试了以下在无根(stock Android 6.0)手机上的操作:
在 session #1 中:
screenrecord /sdcard/Movies/test.mpg
在 session #2 中:
pkill -INT screenrecord
screenrecord
捕获在发出 pkill
命令后停止
关于java - 如何从 Java 在 Android 设备上运行 adb screenrecord 并结束屏幕录制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38363680/
我正在使用 Selendroid 来测试我的应用程序。在每次测试开始时,我使用以下函数运行 adb shell screenrecord: public static Process startScr
我想创建一个应用程序,它在单击按钮时执行 adb shell screenrecord 命令。 我已经尝试过 Runtime.getRuntime().exec() 方法,但是没有用。我首先在模拟器上
我使用的是装有 v4.4.4 Android 的 Droid Maxx。我正在尝试: adb shell screenrecord /sdcard/myvideo.mp4 而且我能够捕捉视频,显示桌面
我无法运行 adb shell screenrecord/sdcard/my.mp4 我正在尝试运行此命令的设备规范: 荣誉5C 安卓6.0 每当我运行 screenrecord 命令时,它都会显示找
我有一台装有 Android 5.0.2 的 Android 电视。我正在尝试使用 adb 命令中的命令 screenrecord,但它从未开始录制,它只是生成一个空的 mp4 文件。 正如您在图片中
这是我的命令和输出: shell@kltexzy:/sdcard $ screenrecord --verbose tmp.mp4 Main displ
在 linux 下,我使用下面的代码将 android 屏幕转换到 pc,效果很好 adb shell "screenrecord --time-limit 1 --output-format=h26
我正在尝试从终端创建视频,但我无法成功。它在这样的终端上给出错误。 adb shell screenrecord /sdcard/screenshotyyyy.mp4 ERROR: unable t
如何从 Java 在 Android 设备上运行 adb shell screenrecord 并结束 screenrecording? 目前我必须指定--time-limit 来结束录制。如果我尝试
我已经尝试了 fadden 的建议将Android屏幕镜像到PC,但vlc播放器屏幕不显示: 该函数的正确命令行是什么?谢谢。 最佳答案 由于 vlc 无法从 adb std 输出播放 h264 文件
我是一名优秀的程序员,十分优秀!