-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to record video from a front camera without a mirror❓ #2338
Comments
So I added also some hack that works for android. VideoPipeline.kt
onFrame(transformMatrix) -> onFrame(transformMatrix, isMirrored)
private external fun onFrame(transformMatrix: FloatArray) -> private external fun onFrame(transformMatrix: FloatArray, isMirrored: Boolean) VideoPipeline.cpp
void VideoPipeline::onFrame(jni::alias_ref<jni::JArrayFloat> transformMatrixParam) { -> void VideoPipeline::onFrame(jni::alias_ref<jni::JArrayFloat> transformMatrixParam, bool isMirrored) {
_recordingSessionOutput->renderTextureToSurface(texture, transformMatrix); -> _recordingSessionOutput->renderTextureToSurface(texture, transformMatrix, isMirrored); VideoPipeline.h
void onFrame(jni::alias_ref<jni::JArrayFloat> transformMatrix); -> void onFrame(jni::alias_ref<jni::JArrayFloat> transformMatrix, bool isMirrored); OpenGLRenderer.cpp
void OpenGLRenderer::renderTextureToSurface(const OpenGLTexture& texture, float* transformMatrix) { -> void OpenGLRenderer::renderTextureToSurface(const OpenGLTexture& texture, float* transformMatrix, bool isMirrored) {
_passThroughShader.draw(texture, transformMatrix); -> _passThroughShader.draw(texture, transformMatrix, isMirrored); OpenGLRenderer.h
void renderTextureToSurface(const OpenGLTexture& texture, float* transformMatrix); -> void renderTextureToSurface(const OpenGLTexture& texture, float* transformMatrix, bool isMirrored); PassThroughShader.cpp
void PassThroughShader::draw(const OpenGLTexture& texture, float* transformMatrix) { -> void PassThroughShader::draw(const OpenGLTexture& texture, float* transformMatrix, bool isMirrored) {
_programId = createProgram(); -> _programId = createProgram(isMirrored);
GLuint PassThroughShader::createProgram() { -> GLuint PassThroughShader::createProgram(bool isMirrored) {
GLuint fragmentShader = loadShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER); -> GLuint fragmentShader;
if (isMirrored) {
fragmentShader = loadShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER_FLIPPED);
} else {
fragmentShader = loadShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
} PassThroughShader.h
void draw(const OpenGLTexture& texture, float* transformMatrix); -> void draw(const OpenGLTexture& texture, float* transformMatrix, bool isisMirrored);
static GLuint createProgram(); -> static GLuint createProgram(bool isisMirrored);
static constexpr char FRAGMENT_SHADER_FLIPPED[] = R"(
#extension GL_OES_EGL_image_external : require
precision mediump float;
varying vec2 vTexCoord;
uniform samplerExternalOES uTexture;
void main() {
gl_FragColor = texture2D(uTexture, vec2(vTexCoord.x, 1.0 - vTexCoord.y));
}
)"; |
It doesn't work in my case on iOS with the same react-native-vision-camera. Could you say what iOS device you use? Also, could you send your Camera component JSX (if something differs here)? |
What VisionCamera Version are you using?
it works for all IOS devices |
@HorbachAndrii thank you for your quick response!
I tried with 3.6.16 (as you mentioned) and 3.9.2. I tested with iPhone 11. |
here is my AVCaptureOutput+mirror.swift file
|
Did you 'Clean Build Folder' before building the app? |
|
Hey all! I just spent some time to build a new feature: I created a PR to add a 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 thank you for introducing new features! However, in this issue, we needed Preview to be not mirrored in the front camera, but it isn't supported:
|
This is intentional - if the preview was mirrored the app would be pretty unusable because every movement goes in the wrong direction. All camera apps mirror the front preview. If you really really need the preview not mirrored for whatever reason, you can just apply a |
Question
I am analyzing recorded video and for me, it matters to record video without a mirror.
For IOS, I added some hack. I changed this
connection.isVideoMirrored = false
(from true to false) atnode_modules/react-native-vision-camera/ios/Extensions/AVCaptureOutput+mirror.swift
.react-native-vision-camera/package/ios/Extensions/AVCaptureOutput+mirror.swift
Line 19 in ef4e9fa
But for Android, I don't know how to record video from a front camera without a mirror.
Maybe somebody knows how can I record video from a front camera without a mirror?
What I tried
I changing the Matrix for transformMatrix in VideoPipeline.kt and other stuff, but nothing helped
VisionCamera Version
3.6.16
Additional information
The text was updated successfully, but these errors were encountered: