react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

🐛 [iOS]: Resulting video recording is mirrored

Open deevus opened this issue 3 years ago • 3 comments

What were you trying to do?

Record a video on iOS.

Reproduceable Code

No response

What happened instead?

The preview is mirrored as expected, however the resulting video is unchanged (i.e. still mirrored).

It looks as though it might have been a sneaky iOS change at some point in the last month or 2. We haven't released a new major version of our app since March, however some users have recently reported this issue in the last few weeks.

Relevant log output

No response

Device

iPhone Xs Max iOS 15.6, iPhone 13 Pro Max iOS 15.x

VisionCamera Version

2.12.0, 2.14.1

Additional information

deevus avatar Aug 17 '22 01:08 deevus

I don't know how I missed adding a title, but I'm not surprised this was missed.

deevus avatar Sep 07 '22 01:09 deevus

@mrousavy Any ideas why this would be happening? Or a temporary fix?

deevus avatar Sep 07 '22 01:09 deevus

The following patch appears to fix the issue in my limited testing.

diff --git a/node_modules/react-native-vision-camera/ios/CameraView+Orientation.swift b/node_modules/react-native-vision-camera/ios/CameraView+Orientation.swift
index 5c6db1f..880c934 100644
--- a/node_modules/react-native-vision-camera/ios/CameraView+Orientation.swift
+++ b/node_modules/react-native-vision-camera/ios/CameraView+Orientation.swift
@@ -49,10 +49,10 @@ extension CameraView {
         // Run those updates on cameraQueue since they can be blocking.
         self.captureSession.outputs.forEach { output in
           output.connections.forEach { connection in
-            if connection.isVideoMirroringSupported {
-              connection.automaticallyAdjustsVideoMirroring = false
-              connection.isVideoMirrored = isMirrored
-            }
+            /*if connection.isVideoMirroringSupported {*/
+              /*connection.automaticallyAdjustsVideoMirroring = false*/
+              /*connection.isVideoMirrored = isMirrored*/
+            /*}*/
             connection.setInterfaceOrientation(connectionOrientation)
           }
         }

deevus avatar Sep 07 '22 03:09 deevus

Will be enough to set false to isVideoMirrored in the CameraView+Orientation.swift file connection.isVideoMirrored = false

https://github.com/mrousavy/react-native-vision-camera/blob/3ed019d018cce9ff20afb0fcc81146732419f17e/ios/CameraView%2BOrientation.swift#L39

HorbachAndrii avatar Jul 05 '23 19:07 HorbachAndrii

I wonder what automaticallyAdjustsVideoMirroring actually does?

mrousavy avatar Jul 06 '23 08:07 mrousavy

I wonder what automaticallyAdjustsVideoMirroring actually does?

As I understand correctly the automaticallyAdjustsVideoMirroring automatically adjusts the video mirroring based on the capture device's position, while isVideoMirrored allows you to explicitly set whether the video should be mirrored or not, overriding the automatic behavior.

I think it is nice to have a property for the activation mirror.

HorbachAndrii avatar Jul 06 '23 08:07 HorbachAndrii

I believe in all of the Cameras I have used so far, I want the selfie cam to be mirrored (which is exactly what Snapchat and Instagram are doing). If the resulting video/photo is not mirrored, it feels weird and looks off.

I can add this prop to the backlog but will put this on very low priority as there are just a million things to do with V3 right now

mrousavy avatar Jul 06 '23 08:07 mrousavy

Closing as this is a stale issue - this might have been fixed with the full rewrite in VisionCamera V3 (🥳) - if not, please create a new issue.

Video Mirroring is default for front camera

mrousavy avatar Sep 30 '23 09:09 mrousavy

Hey all! I just spent some time to build a new feature: I created a PR to add a isMirrored prop to Camera: https://github.com/mrousavy/react-native-vision-camera/pull/3036

With this prop you can enable or disable output mirroring 🎉🥳

If you appreciate my time and dedication towards building new features and constantly improving this library, please consider sponsoring me on GitHub :)

mrousavy avatar Jul 02 '24 10:07 mrousavy