mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
6.64k stars 983 forks source link

🐛 Selfie camera recording on Android is inverted / upside down #2828

Closed likecarson closed 2 weeks ago

likecarson commented 2 weeks ago

What's happening?

Recording video using selfie mode on Android device is upside down / inverted. While recording the video is correct orientation but when playing back the recorded video it is inverted.

Reproduceable Code

 const onStartRecording = () => {
    setDescriptionIsOpen(false);
    setRecodingState('recording');
    onRecordingStarted();
    cameraRef.current?.startRecording({
      videoCodec: 'h265',
      onRecordingFinished: (video) => {
        stopCountdown();
        stopStopWatch();
        onRecordingFinished(video);
        setTimeout(() => {
          setCountdown(0);
          setRecodingState('idle');
          setIsFrontCamera(false);
        }, 150);
      },
      onRecordingError: (error) => {
        stopCountdown();
        stopStopWatch();
        onRecordingError?.(error);
      },
    });
    startCountdown();
    startStopWatch();
  };

        <VisionCamera
          ref={mergeRefs}
          audio
          enableZoomGesture
          focusable
          video
          device={device}
          format={bestVideoFormat}
          isActive={isAppForeground && isFocused}
          orientation="portrait"
          photo={false}
          pixelFormat="yuv"
          style={StyleSheet.absoluteFill}
          torch={device.hasTorch ? (torchEnabled ? 'on' : 'off') : 'off'}
          videoHdr={false}
          videoStabilizationMode="off"
          zoom={device.neutralZoom}
        />

<Camera
        ref={videoRecorder}
        enableZoomGesture
        video
        device={device}
        format={bestVideoFormat}
        isActive={isAppForeground && isFocused}
        style={STYLES.camera}
      />

Relevant log output

No error logs for this, everything records fine it just show the recording as inverted.

Camera Device

no device info, but can reproduce on Android emulator, and production Pixel devices.

Device

Pixel 5 (Android 14), Pixel 7 (Android 14)

VisionCamera Version

4.0.1

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

mrousavy commented 2 weeks ago

no device info, but can reproduce on Android emulator, and production Pixel devices.

Without the device info, I have no idea what your scenario or environment is like.

No error logs for this, everything records fine it just show the recording as inverted.

Without error logs I don't know what is happening before recording and how the Camera sets up the Media Encoder.

Closing due to lack of information