我怎样才能跑adb shell screenrecord
on a Android
设备来自Java
并结束screenrecording
?
目前我必须指定--time-limit
结束录音。如果我尝试在视频结束之前捕获视频,则会失败。
有没有办法告诉adb停止录制?有没有办法配置线程发送CTRL-C
to the shell
命令?
这将在未 root 的手机上运行。
Code
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
or SIGHUP
to screenrecord https://android.googlesource.com/platform/frameworks/av/+/master/cmds/screenrecord/screenrecord.cpp进程将导致其停止记录。
我刚刚在未root的(原生Android 6.0)手机上尝试了以下2个单独的操作adb shell
会议:
在会话 #1 中:
screenrecord /sdcard/Movies/test.mpg
在会话 #2 中:
pkill -INT screenrecord
and the screenrecord
发出后捕获停止pkill
command
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)