diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java b/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java index 47c0a166..2850d483 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java @@ -3,12 +3,10 @@ package com.sparrowwallet.sparrow.control; import com.sparrowwallet.drongo.OsType; public enum WebcamPixelFormat { - PIX_FMT_420V("420v", true, true), - PIX_FMT_YUVS("yuvs", true, true), + //Only V4L2 formats defined in linux/videodev2.h are required here PIX_FMT_RGB24("RGB3", true, true), PIX_FMT_YUYV("YUYV", true, true), PIX_FMT_MJPG("MJPG", true, false), - PIX_FMT_YUY2("YUY2", true, true), PIX_FMT_NV12("NV12", false, false); private final String name; diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java b/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java index 1073bf0a..8350daf7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java @@ -5,6 +5,7 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.common.HybridBinarizer; import com.google.zxing.qrcode.QRCodeReader; import com.sparrowwallet.bokmakierie.Bokmakierie; +import com.sparrowwallet.drongo.OsType; import com.sparrowwallet.sparrow.io.Config; import javafx.beans.property.BooleanProperty; import javafx.beans.property.ObjectProperty; @@ -135,11 +136,16 @@ public class WebcamService extends ScheduledService { } List deviceFormats = new ArrayList<>(device.getFormats()); - deviceFormats.sort((f1, f2) -> { - WebcamPixelFormat pf1 = WebcamPixelFormat.fromFourCC(f1.getFormatInfo().fourcc); - WebcamPixelFormat pf2 = WebcamPixelFormat.fromFourCC(f2.getFormatInfo().fourcc); - return Integer.compare(WebcamPixelFormat.getPriority(pf1), WebcamPixelFormat.getPriority(pf2)); - }); + + //On *nix prioritise supported camera pixel formats, preferring RGB3 and YUYV over MJPG + //On macOS and Windows, camera pixel format is largely abstracted away + if(OsType.getCurrent() == OsType.UNIX) { + deviceFormats.sort((f1, f2) -> { + WebcamPixelFormat pf1 = WebcamPixelFormat.fromFourCC(f1.getFormatInfo().fourcc); + WebcamPixelFormat pf2 = WebcamPixelFormat.fromFourCC(f2.getFormatInfo().fourcc); + return Integer.compare(WebcamPixelFormat.getPriority(pf1), WebcamPixelFormat.getPriority(pf2)); + }); + } Map supportedResolutions = deviceFormats.stream() .filter(f -> WebcamResolution.from(f) != null)