浏览代码

Make sure the output settings match the camera device format

Sam Lantinga 1 年之前
父节点
当前提交
463984ec20
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/camera/coremedia/SDL_camera_coremedia.m

+ 5 - 1
src/camera/coremedia/SDL_camera_coremedia.m

@@ -308,7 +308,11 @@ static int COREMEDIA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *
         return SDL_SetError("Cannot create AVCaptureVideoDataOutput");
     }
 
-    output.videoSettings = @{};
+    output.videoSettings = @{
+        (id)kCVPixelBufferWidthKey : @(spec->width),
+        (id)kCVPixelBufferHeightKey : @(spec->height),
+        (id)kCVPixelBufferPixelFormatTypeKey : @(CMFormatDescriptionGetMediaSubType([spec_format formatDescription]))
+    };
 
     char threadname[64];
     SDL_GetCameraThreadName(device, threadname, sizeof (threadname));