Closed cvphat closed 1 year ago
Apparently, this error corresponds to [an encoding problem](https://developer.android.com/reference/androidx/camera/video/VideoRecordEvent.Finalize#ERROR_ENCODING_FAILED()).
I ran your example and found an error in the logcat:
2023-03-27 11:46:10.431 30125-1607 ACodec com.example.test_camera_awesome E [OMX.qcom.video.encoder.avc] ERROR(0x80001009)
2023-03-27 11:46:10.431 30125-1607 ACodec com.example.test_camera_awesome E signalError(omxError 0x80001009, internalError -2147483648)
2023-03-27 11:46:10.431 30125-1606 MediaCodec com.example.test_camera_awesome E Codec reported err 0x80001009, actionCode 0, while in state 6
2023-03-27 11:46:10.433 30125-30237 VideoEncoder com.example.test_camera_awesome D Transitioning encoder internal state: STARTED --> ERROR
2023-03-27 11:46:10.449 30125-30237 SequentialExecutor com.example.test_camera_awesome E Exception while executing runnable androidx.camera.video.internal.encoder.EncoderImpl$$ExternalSyntheticLambda6@ed6964b
java.lang.IllegalStateException
at android.media.MediaCodec.native_flush(Native Method)
at android.media.MediaCodec.flush(MediaCodec.java:2298)
at androidx.camera.video.internal.encoder.EncoderImpl.lambda$stopMediaCodec$11$androidx-camera-video-internal-encoder-EncoderImpl(EncoderImpl.java:823)
at androidx.camera.video.internal.encoder.EncoderImpl$$ExternalSyntheticLambda6.run(Unknown Source:6)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Not sure yet why this happens, I'll investigate a bit more.
Sometimes, The video output can not be played by video_player plugin. I can not replicate this issue. I don't remember exactly the error message but it relates to video codec. Not sure if it relates to this issue
After some tries, I believe that the issues arise when there's a video player in the widget tree. I think it works until there is a video recorded. Once one is recorded, it's loaded into the main.dart screen and that's when video recording stop working with this strange error. I commented the part that show the videos and I can't reproduce the bug anymore, even when recording several videos. Is it the same for you ?
Is it the same for you ?
Yes, When I remove video player out the widget tree. The issue is not happened
My guess is that the same codec is used for the video player and then for the video recording but can't handle both at the same time. Not sure what we can do to help. I would suggest to try to remove the video player from your widget tree before recording a video, and once it's done show again the video player.
Yeah, I think I have a way to workaround. Thank you
Closing since there is a workaround.
Steps to Reproduce
I see only the first record is success all the action record after that always show
Video capture ends with error: 6
Expected results
Actual results
Video capture ends with error: 6
MediaCaptureStatus
isMediaCaptureStatus.success
About your device
Your flutter version
Run this in your command line
flutter --version
Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git Framework • revision 2ad6cd72c0 (2 weeks ago) • 2023-03-08 09:41:59 -0800 Engine • revision 1837b5be5f Tools • Dart 2.19.4 • DevTools 2.20.1