natario1 / CameraView

📸 A well documented, high-level Android interface that makes capturing pictures and videos easy, addressing all of the common issues and needs. Real-time filters, gestures, watermarks, frame processing, RAW, output of any size.
https://natario1.github.io/CameraView
Other
4.92k stars 927 forks source link

Not able to record video in android 14 in some devices #1282

Open rakeshrajput537 opened 1 month ago

rakeshrajput537 commented 1 month ago

Describe the bug

I have two android 14 devices one is oneplus and another one is vivp. in my oneplus it is working fine but failing in vivo.

To Reproduce

Start video recording in android 14 in vivo phone.

Expected behavior

Should record video as expect

XML layout

Part of the XML layout with the CameraView declaration, so we can read its attributes.

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.otaliastudios.cameraview.CameraView
        android:id="@+id/camera"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:keepScreenOn="true"
        app:layout_constraintBottom_toTopOf="@+id/bottomPanel"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Logs

onVideoResult result is null: something went wrong. java.lang.RuntimeException: start failed. java.lang.RuntimeException: start failed. at android.media.MediaRecorder._start(Native Method) at android.media.MediaRecorder.start(MediaRecorder.java:1376) at com.otaliastudios.cameraview.video.FullVideoRecorder.onStart(FullVideoRecorder.java:314) at com.otaliastudios.cameraview.video.VideoRecorder.start(VideoRecorder.java:80) at com.otaliastudios.cameraview.engine.Camera1Engine.onTakeVideo(Camera1Engine.java:426) at com.otaliastudios.cameraview.engine.CameraBaseEngine$5.run(CameraBaseEngine.java:605) at com.otaliastudios.cameraview.engine.orchestrator.CameraStateOrchestrator$3.run(CameraStateOrchestrator.java:100) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$1.call(CameraOrchestrator.java:84) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$1.call(CameraOrchestrator.java:81) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$3.run(CameraOrchestrator.java:152) at com.otaliastudios.cameraview.internal.WorkerHandler.run(WorkerHandler.java:137) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator.execute(CameraOrchestrator.java:147) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator.access$100(CameraOrchestrator.java:34) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$2.run(CameraOrchestrator.java:137) at android.os.Handler.handleCallback(Handler.java:1013) at android.os.Handler.dispatchMessage(Handler.java:101) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:328) at android.os.HandlerThread.run(HandlerThread.java:67)

Rohitrajkhorwal commented 1 month ago

Are you getting this error with cameraEngine camera2 also? And did you change its mode before recording the video?

camera.mode = Mode.VIDEO

rakeshrajput537 commented 1 month ago

Yes I change the mode to video, I didn't try cameraEngine and camera2

On Mon, 29 Jul 2024, 5:30 pm Rohitraj Khorwal, @.***> wrote:

Are you getting this error with cameraEngine camera2 also? And did you change its mode before recording the video?

camera.mode = Mode.VIDEO

— Reply to this email directly, view it on GitHub https://github.com/natario1/CameraView/issues/1282#issuecomment-2255743223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXALMXPVJ57AS6WPEZYOMDZOYVHJAVCNFSM6AAAAABLT7YBOGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJVG42DGMRSGM . You are receiving this because you authored the thread.Message ID: @.***>

rakeshrajput537 commented 1 month ago

How to use camera2 or camera engine?

On Mon, 29 Jul 2024, 6:46 pm Rakesh Kumar, @.***> wrote:

Yes I change the mode to video, I didn't try cameraEngine and camera2

On Mon, 29 Jul 2024, 5:30 pm Rohitraj Khorwal, @.***> wrote:

Are you getting this error with cameraEngine camera2 also? And did you change its mode before recording the video?

camera.mode = Mode.VIDEO

— Reply to this email directly, view it on GitHub https://github.com/natario1/CameraView/issues/1282#issuecomment-2255743223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXALMXPVJ57AS6WPEZYOMDZOYVHJAVCNFSM6AAAAABLT7YBOGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJVG42DGMRSGM . You are receiving this because you authored the thread.Message ID: @.***>

AntonLogin0v commented 1 month ago

I have the same problem

AntonLogin0v commented 1 month ago

@rakeshrajput537 The problem is in the methods

mediaRecorder.setVideoSize(mProfile.videoFrameWidth, mProfile.videoFrame Height); mediaRecorder.setVideoFrameRate(mProfile.videoFrameRate);

works for me, comment them out(download lib), but they affect the quality

source: https://blog.csdn.net/netwalk/article/details/17686993

also works, set mProfile custom quality(1080p)