Issues with CameraX video library

816 views
Skip to first unread message

Mohit Shetty

unread,
Oct 14, 2021, 5:59:51 AM10/14/21
to Android CameraX Discussion Group
Thanks a lot for officially releasing the video capture library....the pause/resume option and video quality option addition, will help making our camera apps a lot better for our users.

I recently tried replacing the old video capture api with the new one and noticed two major issues...

1. Unlike the previous API, there wasn't any proper mechanism for error handling...when the video gets saved. So it's hard to know what actually went wrong when a video doesn't get saved. E.g. Sometimes the recording is too is too short to be saved, so the earlier API had an option to handle that well with the onError callback which passed an message, error code and throwable, which made debugging the issue and displaying an appropriate message to the user a lot more easier. I tried stopping the recording as soon as I started and found that using a try-catch doesn't really help (at least in this case), and my app just crashes when it manually tries to generate a thumbnail for the recording that is assumed to be saved (locally storing the video uri from output options for now).

This issue could be handled by checking if the generated file exists or not, but handling video capture uri sent by another app could get a lot more tricker.

2. I get these logs after calling stop() on an ActiveRecording. Not sure if it is something to be concerned about..

```
E/FMQ: grantorIdx must be less than 3
E/ion: ioctl c0044901 failed with code -1: Inappropriate ioctl for device
[...]
E/MPEG4Writer: Stop() called but track is not started or stopped
[...]
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
E/BufferQueueConsumer: [GraphicBufferSource](id:457700000005,api:4,p:1022,c:17783) acquireBuffer: max acquired buffer count reached: 17 (max 16)
W/GraphicBufferSource: acquireBuffer_l: failed with err=-38
E/GraphicBufferSource: onFrameAvailable: acquireBuffer returned err=-38
```

Bringing this library out might have been a lot of work and I really appreciate the efforts taken by the CameraX team :)

Hope the library truly achieves its targets/goal in the near future!

Regards,
Mohit

Gerry Fan

unread,
Oct 14, 2021, 11:51:09 AM10/14/21
to Mohit Shetty, Android CameraX Discussion Group
Hey Mohit,

Thank you for trying the video capture out,  appreciate your sharing of your experience -- this is more important par :-)!

For the 1) you mentioned:
Once recording is started,  the communication to app is via VideoCaptureEvent(start, pause, resume, finalize, status)
  - the finalize message has error code(can be used to evaluate final result),
  - Status event is sent routinely during the recording
  - event.recordingStats is inside all event types, and it has the recorded bytes and time stamp

EventHander can be registered with PendingRecording::withEventListener() (I think app has to register an event listener, it is the only way to know exactly when capture is complete).
It is noticed that if you stop before the previous start got really started, the capture is canceled and get the 0 file size, so check for the Finalize error code would be helpful(will add some checking in the sample);
and also check for the file size(sample does that when displaying fragment).

for the 2):  there is a bug logged for it, I believe the fix is close to being checked in.

Again appreciate your sharing and love to hear more from you about the new API (and CameraX overall, even doc and sample code)!

gerry

--
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/b65df514-d7ad-4f4d-976e-cbeb5617ea9cn%40android.com.
Reply all
Reply to author
Forward
0 new messages