mrousavy / react-native-vision-camera

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

🐛 After recording many videos on Pixel 5, video stops recording #1212

Closed arcticfly closed 1 year ago

arcticfly commented 2 years ago

What were you trying to do?

I was trying to record many short videos on my Pixel 5.

Reproduceable Code

I think the easiest way to reproduce this code is to clone the simple react-native repository I created to reproduce the bug: 

https://github.com/davidlcorbitt/recording-error-example

What happened instead?

After recording anywhere from 30-60 recordings without error, the video will suddenly stop recording properly, usually partway through a recording. The video preview will start pulsing about once a second. Audio continues to be saved correctly to that specific recording, but video stops saving suddenly. After that recording finishes and another one begins, no video or audio is saved to the next recording (although no error is thrown until the recording stops). When the recording is stopped, onRecordingError receives the following error:

{
    "cause": {
        "message": "[capture/no-valid-data] The recording failed because no valid data was produced to be recorded.
            This error is generated when the essential data for a recording to be played correctly is missing, for example, a recording must contain at least one key frame. The application will need to clean up the output file, such as deleting the file.",
        "stacktrace": "com.mrousavy.camera.NoValidDataError: [capture/no-valid-data] The recording failed because no valid data was produced to be recorded.
            This error is generated when the essential data for a recording to be played correctly is missing, for example, a recording must contain at least one key frame. The application will need to clean up the output file, such as deleting the file.
                at com.mrousavy.camera.CameraView_RecordVideoKt$startRecording$1.accept(CameraView+RecordVideo.kt:62)
                at com.mrousavy.camera.CameraView_RecordVideoKt$startRecording$1.accept(CameraView+RecordVideo.kt:52)
                at androidx.camera.video.Recorder$RecordingRecord.lambda$updateVideoRecordEvent$6$androidx-camera-video-Recorder$RecordingRecord(Recorder.java:2624)
                at androidx.camera.video.Recorder$RecordingRecord$$ExternalSyntheticLambda6.run(Unknown Source:4)
                at android.os.Handler.handleCallback(Handler.java:942)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loopOnce(Looper.java:201)
                at android.os.Looper.loop(Looper.java:288)
                at android.app.ActivityThread.main(ActivityThread.java:7898)
                at java.lang.reflect.Method.invoke(Native Method)
                at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)"
    },
    "code": "capture/no-valid-data",
    "message": "[capture/no-valid-data] The recording failed because no valid data was produced to be recorded. This error is generated when the essential data for a recording to be played correctly is missing, for example, a recording must contain at least one key frame. The application will need to clean up the output file, such as deleting the file.",
    "userInfo": null
}

The majority of the recordings after the first messed up recording also seem to be empty and throw an error. On occasion a recording will be able to save, but usually the next recording will also throw an error.

Relevant log output

I/ReactNativeJS: Starting a new recording
D/RecordVideo: file is "/data/user/0/<bundle-id>/cache/VisionCamera-20220824_1655345588239996310333588.mp4"
D/Recorder: Transitioning Recorder internal state: IDLING --> PENDING_RECORDING
D/Recorder: Transitioning Recorder internal state: PENDING_RECORDING --> RECORDING
D/Recorder: Sent VideoRecordEvent class androidx.camera.video.VideoRecordEvent$Start
D/VideoEncoder: Start on 68:46:01.125
D/MediaCodec: keep callback message for reclaim
W/Codec2Client: query -- param skipped: index = 1342179345.
W/Codec2Client: query -- param skipped: index = 2415921170.
W/Codec2Client: query -- param skipped: index = 1610614798.
D/CCodecBufferChannel: [c2.qti.avc.encoder#78] Query input allocators returned 0 params => BAD_INDEX (6)
D/CCodecBufferChannel: [c2.qti.avc.encoder#78] Using basic input block pool with poolID 1 => got 1 - OK (0)
D/CCodecBufferChannel: [c2.qti.avc.encoder#78] Query output allocators returned 0 params => BAD_INDEX (6)
I/CCodecBufferChannel: [c2.qti.avc.encoder#78] Created output block pool with allocatorID 16 => poolID 2238 - OK
D/CCodecBufferChannel: [c2.qti.avc.encoder#78] Configured output block pool ids 2238 => OK
D/VideoEncoder: Transitioning encoder internal state: CONFIGURED --> STARTED
D/Camera2CameraImpl: {Camera@9d1261d[id=0]} Use case androidx.camera.video.VideoCapture-044dd978-12c3-4df2-a41b-de7bad972427242771473 UPDATED
D/UseCaseAttachState: Active and attached use case: [androidx.camera.video.VideoCapture-044dd978-12c3-4df2-a41b-de7bad972427242771473, androidx.camera.core.Preview-e92b375b-187c-4698-aefb-9a1dc3a4c408133334584] for camera: 0
D/CaptureSession: Attempting to submit CaptureRequest after setting
D/CaptureSession: Issuing request for session.
D/ReactNativeJS: Skipping autofocusing on center for Android device
D/Recorder: Video source has transitioned to state: ACTIVE_STREAMING
D/Recorder: Transitioning Recorder internal state: RECORDING --> STOPPING
D/VideoEncoder: Transitioning encoder internal state: STARTED --> STOPPING
D/VideoEncoder: Stop on 68:46:04.724
D/Camera2CameraImpl: {Camera@9d1261d[id=0]} Issue capture request
D/CaptureSession: Issuing capture request.
D/VideoEncoder: Drop buffer by invalid buffer size.
D/VideoEncoder: Transitioning encoder internal state: STOPPING --> CONFIGURED
D/Recorder: Encodings end successfully.
D/Recorder: Sent VideoRecordEvent class androidx.camera.video.VideoRecordEvent$Finalize
D/Recorder: Transitioning Recorder internal state: STOPPING --> IDLING
D/UseCaseAttachState: Active and attached use case: [androidx.camera.video.VideoCapture-044dd978-12c3-4df2-a41b-de7bad972427242771473, androidx.camera.core.Preview-e92b375b-187c-4698-aefb-9a1dc3a4c408133334584] for camera: 0
D/CaptureSession: Attempting to submit CaptureRequest after setting
D/CaptureSession: Issuing request for session.
D/Camera2CameraImpl: {Camera@9d1261d[id=0]} Issue capture request
D/CaptureSession: Issuing capture request.
D/UseCaseAttachState: Active and attached use case: [androidx.camera.video.VideoCapture-044dd978-12c3-4df2-a41b-de7bad972427242771473, androidx.camera.core.Preview-e92b375b-187c-4698-aefb-9a1dc3a4c408133334584] for camera: 0
D/CaptureSession: Attempting to submit CaptureRequest after setting
D/CaptureSession: Issuing request for session.
D/Camera2CameraImpl: {Camera@9d1261d[id=0]} Use case androidx.camera.video.VideoCapture-044dd978-12c3-4df2-a41b-de7bad972427242771473 UPDATED
D/UseCaseAttachState: Active and attached use case: [androidx.camera.video.VideoCapture-044dd978-12c3-4df2-a41b-de7bad972427242771473, androidx.camera.core.Preview-e92b375b-187c-4698-aefb-9a1dc3a4c408133334584] for camera: 0
D/CaptureSession: Attempting to submit CaptureRequest after setting
D/CaptureSession: Issuing request for session.
I/ReactNativeJS: { userInfo: null,
      message: '[capture/no-valid-data] The recording failed because no valid data was produced to be recorded.\nThis error is generated when the essential data for a recording to be played correctly is missing, for example, a recording must contain at least one key frame. The application will need to clean up the output file, such as deleting the file.',
      cause: 
       { stacktrace: 'com.mrousavy.camera.NoValidDataError: [capture/no-valid-data] The recording failed because no valid data was produced to be recorded.\nThis error is generated when the essential data for a recording to be played correctly is missing, for example, a recording must contain at least one key frame. The application will need to clean up the output file, such as deleting the file.\n\tat com.mrousavy.camera.CameraView_RecordVideoKt$startRecording$1.accept(CameraView+RecordVideo.kt:64)\n\tat com.mrousavy.camera.CameraView_RecordVideoKt$startRecording$1.accept(CameraView+RecordVideo.kt:54)\n\tat androidx.camera.video.Recorder$RecordingRecord.lambda$updateVideoRecordEvent$6$androidx-camera-video-Recorder$RecordingRecord(Recorder.java:2624)\n\tat androidx.camera.video.Recorder$RecordingRecord$$ExternalSyntheticLambda6.run(Unknown Source:4)\n\tat android.os.Handler.handleCallback(Handler.java:942)\n\tat android.os.Handler.dispatchMessage(Handler.java:99)\n\tat android.os.Looper.loopOnce(Looper.java:201)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.app.ActivityThread.main(ActivityThread.java:7898)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)\n',
         message: '[capture/no-valid-data] The recording failed because no valid data was produced to be recorded.\nThis error is generated when the essential data for a recording to be played correctly is missing, for example, a recording must contain at least one key frame. The application will need to clean up the output file, such as deleting the file.' },
      code: 'capture/no-valid-data' }
D/Recorder: Video source has transitioned to state: ACTIVE_NON_STREAMING
I/hw-BpHwBinder: onLastStrongRef automatically unlinking death recipients
D/CCodec: allocate(c2.qti.avc.encoder)
I/CCodec: setting up 'default' as default (vendor) store
I/CCodec: Created component [c2.qti.avc.encoder]
D/CCodecConfig: read media type: video/avc
D/ReflectedParamUpdater: extent() != 1 for single value type: vendor.qti-ext-enc-info-metadata-cvp.reserved
D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater: extent() != 1 for single value type: vendor.qti-ext-enc-info-ltr.ltrinfo
D/ReflectedParamUpdater: ignored struct field coding.gop.values
D/CCodecConfig: ignoring local param raw.color (0xc2001809) as it is already supported
I/CCodecConfig: query failed after returning 22 values (BAD_INDEX)
D/CCodecConfig: c2 config diff is Dict {
      c2::u32 algo.bitrate-mode.value = 3
      c2::i32 algo.priority.value = -1
      c2::float algo.rate.value = 30
      c2::u32 algo.secure-mode.value = 0
      c2::i32 coded.average-qp.value = 0
      c2::u32 coded.bitrate.value = 20000000
      c2::float coded.frame-rate.value = 30
      c2::u32 coded.picture-type.value = 0
      c2::u32 coded.pl.level = 0
      c2::u32 coded.pl.profile = 20484
      c2::u32 coded.vui.color.matrix = 255
      c2::u32 coded.vui.color.primaries = 0
      c2::u32 coded.vui.color.range = 0
      c2::u32 coded.vui.color.transfer = 255
      c2::u32 coding.intra-refresh.mode = 0
      c2::float coding.intra-refresh.period = 0
      c2::u32 coding.request-sync-frame.value = 0
      c2::i64 coding.sync-frame-interval.value = 1000000
      Buffer coding.temporal-layering = {
        00000000:  10 00 00 00 07 20 01 52  00 00 00 00 00 00 00 00  ..... .R........
      }
      c2::u32 default.color.matrix = 255
      c2::u32 default.color.primaries = 0
      c2::u32 default.color.range = 0
      c2::u32 default.color.transfer = 255
      c2::u32 input.delay.v
W/ColorUtils: expected specified color aspects (0:0:255:255)
I/MediaCodec: MediaCodec will operate in async mode
D/VQApply: minquality: 3840x2160 outside of shaping range
D/MediaCodec: shapeMediaFormat: deltas(1): AMessage(what = 0x00000000) = {
        int32_t android._encoding-quality-level = 0
      }
D/CCodec: [c2.qti.avc.encoder] buffers are bound to CCodec for this session
D/CCodecConfig: no c2 equivalents for color-format
D/CCodecConfig: no c2 equivalents for flags
D/CCodecConfig: no c2 equivalents for encoder
D/CCodecConfig: c2 config diff is   c2::u32 coded.bitrate.value = 36000000
      c2::u32 raw.pixel-format.value = 34
      c2::u32 raw.size.height = 2160
      c2::u32 raw.size.width = 3840
W/ColorUtils: expected specified color aspects (0:0:255:255)
W/Codec2Client: query -- param skipped: index = 3254781982.
D/CCodec: encoding statistics level = 0
D/CCodec: setup formats input: AMessage(what = 0x00000000) = {
      int32_t android._color-format = 2130708361
      Rect crop(0, 0, 3839, 2159)
      int32_t color-standard = 130816
      int32_t color-range = 0
      int32_t color-transfer = 65791
      int32_t video-qp-average = 0
      int32_t width = 3840
      int32_t feature-secure-playback = 0
      int32_t frame-rate = 30
      int32_t height = 2160
      int32_t intra-refresh-period = 0
      string mime = "video/raw"
      int32_t prepend-sps-pps-to-idr-frames = 0
      int32_t priority = 1
      Buffer hdr-static-info = {
        00000000:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
        00000010:  00 00 00 00 00 00 00 00  00                       .........
      }
      int32_t android._dataspace = 12648448
      int64_t android._C2MemoryUsage = 268435456
      int32_t color-format = 2130708361
    }
D/CCodec: setup formats output: AMessage(what = 0x00000000) = {
      int32_t bitrate = 36000000
      int32_t bitrate-mode = 1
      Rect crop(0, 0, 3839, 2159)
      int32_t width = 3840
      int32_t color-standard = 130816
      int32_t color-range = 0
      int32_t color-transfer = 65791
      int32_t feature-secure-playback = 0
      int32_t frame-rate = 30
      int32_t height = 2160
      int32_t intra-refresh-period = 0
      int32_t max-bitrate = 36000000
      string mime = "video/avc"
      int32_t prepend-sps-pps-to-idr-frames = 0
      int32_t priority = 1
      int32_t profile = 8
      int32_t video-qp-average = 0
    }
I/CCodecConfig: query failed after returning 22 values (BAD_INDEX)
D/CCodec: input format changed to AMessage(what = 0x00000000) = {
      int32_t android._color-format = 2130708361
      Rect crop(0, 0, 3839, 2159)
      int32_t color-standard = 6
      int32_t color-range = 2
      int32_t color-transfer = 3
      int32_t video-qp-average = 0
      int32_t width = 3840
      int32_t feature-secure-playback = 0
      int32_t frame-rate = 30
      int32_t height = 2160
      int32_t intra-refresh-period = 0
      string mime = "video/raw"
      int32_t prepend-sps-pps-to-idr-frames = 0
      int32_t priority = 1
      Buffer hdr-static-info = {
        00000000:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
        00000010:  00 00 00 00 00 00 00 00  00                       .........
      }
      int32_t android._dataspace = 281411584
      int64_t android._C2MemoryUsage = 268435456
      int32_t color-format = 2130708361
    }
D/GraphicBufferSource: setting dataspace: 0x10c60000, acquired=0
D/CCodec: ISConfig not changed
E/CameraDevice-JV-0: Receive capture error on unknown request ID 153
E/CameraDevice-JV-0: Receive capture error on unknown request ID 155
D/TrafficStats: tagSocket(105) with statsTag=0xffffffff, statsUid=-1
I/ReactNativeJS: [ { ctime: null,
        mtime: Wed Aug 24 2022 16:55:34 GMT-0600 (MDT),
        name: 'VisionCamera-20220824_1655345588239996310333588.mp4',
        path: '/data/user/0/<bundle-id>/cache/VisionCamera-20220824_1655345588239996310333588.mp4',
        size: 0,
        isFile: [Function: isFile],
        isDirectory: [Function: isDirectory] } ]
D/TrafficStats: tagSocket(161) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats: tagSocket(161) with statsTag=0xffffffff, statsUid=-1
I/ReactNativeJS: Starting a new recording

Device

Pixel 5

VisionCamera Version

2.14.1

Additional information

buildgreatthings commented 2 years ago

Yeah, I get this bug as well.

ShaikRizwan0343 commented 1 year ago

yes i'm getting the same error!!,did you find any solution for this

jaiminbhut commented 1 year ago

Same error!

izuutech commented 1 year ago

Did you sort this? Any solution?

iamabdulhaseeb commented 1 year ago

Any fix on this?

Prasanna7254 commented 1 year ago

Wipe the Data on the Device using Android Studio. Go to Device Manager in the Android Studio, and in the Action section, you will see this option.

mrousavy commented 1 year ago

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.