org.apache.commons.exec.LogOutputStream Java Examples

The following examples show how to use org.apache.commons.exec.LogOutputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScrcpyVideoRecorder.java    From agent with MIT License 5 votes vote down vote up
public synchronized void start() {
    if (isRecording) {
        return;
    }

    countDownLatch = new CountDownLatch(1);

    try {
        videoName = UUIDUtil.getUUID() + ".mp4";
        startCmd = String.format("scrcpy -s %s -Nr %s -b%sM -p %d",
                mobileId,
                videoName,
                App.getProperty("androidRecordVideoBitRate"),
                PortProvider.getScrcpyRecordVideoPort());
        log.info("[{}]start record video, cmd: {}", mobileId, startCmd);
        Terminal.executeAsync(startCmd, new PumpStreamHandler(new LogOutputStream() {
            @Override
            protected void processLine(String line, int i) {
                log.info("[{}]scrcpy: {}", mobileId, line);
                if (line.contains("Recording complete")) {
                    countDownLatch.countDown();
                }
            }
        }));
        isRecording = true;
    } catch (IOException e) {
        isRecording = false;
        throw new RuntimeException(e);
    }
}