Skip to content

Commit

Permalink
linux ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
TTangNingzhi committed Dec 25, 2023
1 parent df5e640 commit 757a41a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/main/java/trackers/ScreenRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ public static ScreenRecorder getInstance() {


private void createEncoder() throws IOException {
grabber = new FFmpegFrameGrabber("desktop");
grabber.setFrameRate(frameRate);

// avfoundation for macOS, gdigrab for Windows, x11grab for Linux
// avfoundation for macOS, gdigrab for Windows, xcbgrab for Linux
if (utils.OSDetector.isMac()) {
grabber = new FFmpegFrameGrabber("1");
grabber.setFormat("avfoundation");
} else if (utils.OSDetector.isWindows()) {
grabber = new FFmpegFrameGrabber("desktop");
grabber.setFormat("gdigrab");
} else if (utils.OSDetector.isUnix()) {
grabber = new FFmpegFrameGrabber(":0.0");
grabber.setFormat("x11grab");
} else {
throw new IOException("Unsupported OS");
}

grabber.setFrameRate(frameRate);
GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration();
grabber.setImageWidth((int) (Toolkit.getDefaultToolkit().getScreenSize().width * config.getDefaultTransform().getScaleX()));
Expand Down

0 comments on commit 757a41a

Please sign in to comment.