Bug when recording on FAT32

159 views
Skip to first unread message

Tomáš Válek

unread,
Jun 16, 2022, 4:04:26 AM6/16/22
to Android CameraX Discussion Group
When you start recording and file is bigger than 2^32-1 bytes (4.2GB) on FAT32 file system, there are tons of Exceptions and video file is unplayable. CameraX should recognize the file system, stop recording and start recording with the new file when file system limit occurs.

E/MediaAdapter: pushBuffer called before start
E/SequentialExecutor: Exception while executing runnable androidx.camera.core.impl.utils.executor.SequentialExecutor$1@8714c28
    java.lang.IllegalStateException: writeSampleData returned an error
        at android.media.MediaMuxer.nativeWriteSampleData(Native Method)
        at android.media.MediaMuxer.writeSampleData(MediaMuxer.java:722)
        at androidx.camera.video.Recorder.writeAudioData(Recorder.java:1800)
        at androidx.camera.video.Recorder$3.onEncodedData(Recorder.java:1718)
        at androidx.camera.video.internal.encoder.EncoderImpl$MediaCodecCallback.lambda$sendEncodedData$3(EncoderImpl.java:994)
        at androidx.camera.video.internal.encoder.EncoderImpl$MediaCodecCallback$$ExternalSyntheticLambda6.run(Unknown Source:4)
        at androidx.camera.core.impl.utils.executor.SequentialExecutor$1.run(SequentialExecutor.java:111)
        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)

Leo Huang

unread,
Jun 16, 2022, 5:10:54 AM6/16/22
to Android CameraX Discussion Group, Tomáš Válek

Hi,

Thanks for raising this bug. CameraX has not handled such cases yet. Open a bug to track https://issuetracker.google.com/236225485.

By the way, currently a possible workaround on the app side is to use OutputOptions.setFileSizeLimit(), and file a new recording when VideoRecordEvent.Finalize.ERROR_FILE_SIZE_LIMIT_REACHED is received.
Tomáš Válek 在 2022年6月16日 星期四下午4:04:26 [UTC+8] 的信中寫道:

Tomáš Válek

unread,
Jun 16, 2022, 5:44:28 AM6/16/22
to Android CameraX Discussion Group, Leo Huang, Tomáš Válek
Yes, I know, but people want to recording longer videos with 4K resolution than 20 minutes for example. Thank you.

Dne čtvrtek 16. června 2022 v 11:10:54 UTC+2 uživatel Leo Huang napsal:

Scott Nien

unread,
Jun 17, 2022, 12:42:09 PM6/17/22
to Tomáš Válek, Android CameraX Discussion Group, Leo Huang
Thanks for reporting this issue. 
We will re-evaluate the priority of this feature. 


--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/d2e19a1c-9e18-4e18-bda6-9a0f03bec3c1n%40android.com.

tonyt...@google.com

unread,
Jun 22, 2022, 6:20:34 AM6/22/22
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, Leo Huang, Tomáš Válek
Hi,
While we are looking into auto file switching feature, could you try to start a new file when it reaches the limit? You may use setFileSizeLimit to assign a file size limit to a recording. When the specified limit is reached, the recording will be automatically finalized with ERROR_FILE_SIZE_LIMIT_REACHED. Then in the VideoRecordEvent listener set at start, you may start a new recording when receive this error. The code would be like:
```
val outputOptions = FileOutputOptions.Builder(file)
        .setFileSizeLimit(limit)
        .build()
recording = recorder.prepareRecording(this, outputOptions)
        .start(executor) { recordEvent ->
            when(recordEvent) {
                is VideoRecordEvent.Finalize -> {
                    if (recordEvent.error == ERROR_FILE_SIZE_LIMIT_REACHED) {
                        // Start a new recording
                    }

                }
            }
        }
```

Tomáš Válek

unread,
Jun 23, 2022, 7:36:48 AM6/23/22
to Android CameraX Discussion Group, tonyt...@google.com, Scott Nien, Android CameraX Discussion Group, Leo Huang, Tomáš Válek
Yes setFileSizeLimit is working. The question is what size limit should be? It depends on architecture 32/64 bit + file system (FAT16/32, ext4, ...). The user wants to record the maximum possible size, like "without limit".

Dne středa 22. června 2022 v 12:20:34 UTC+2 uživatel tonyt...@google.com napsal:
Reply all
Reply to author
Forward
0 new messages