Delay on this.camera.recordAsync?

#1

Trying to use the expo camera to record a video, but there seems to be a 1 second lag when calling camera.recordAsync. I noticed that the recorded video is about 1 second or more behind the actual start of the function (button onpress).

I’m using this with the Camera component, and when I start recording, it seems like there is a one second delay where the Camera component seems to flash/focus/refocus. It seems that once that is done, then the video recording actually starts.

Is this normal or am I doing something wrong?

My function looks like this:

startRecording = async () => {
const tempVideo = await this.camera.recordAsync();
console.log(‘recording started’);
}

0 Likes

#2

Hi @robotron, what platform are you using? Also, is the camera initialized before recording occurs? Camera initializations takes some time to complete.

1 Like

#3

This is on Android. It seems that the very first recording has the longest
lag. It’s a bit faster for all subsequent recording. Maybe this is normal
then.

0 Likes

#4

This is something we can look into. I’m not sure how much is our implementation vs Android hardware.

0 Likes

#5

hi @robotron
is there any chance you could post a snack here or something similar that repros your entire use case? Like, recording video and then playing it back? That would help. I can make an example like that but I probably won’t have time to get to it today.

1 Like

#6

Hello @robotron ! What device are you using exactly? The is probably caused by some initializations that have to happen before the recording can actually start (take a built-in camera app as an example, there’s a picture/video mode in most cases and some time is needed to switch between them). I’ll look at this in more detail soon and will let you know if something can be done about this. Thanks for feedback!

1 Like

#7

@ccheever @aalices Thanks for taking a look. I think I was simply doing something wrong. I was checking/asking for permissions by calling the expo permissions API each time on a recording screen, and it was adding to the lag.

I have tested this on an Iphone 7 and a Motorola G3 running android 7. It is much snappier on the Iphone 7, but there is always a second of delay before actual recording starts. I noticed that this seems to occur on apps like Instagram as well, so it might just be par for the course.

Anything I should be doing to initialize the camera beforehand? Thanks!

0 Likes

#8

You can initialize the camera and just not show it. That’s what apps like Snapchat do. They always start the camera as soon as the app starts and just keep it running in case you switch to the camera screen. This takes more battery and processing power obviously which is why its not the norm.

1 Like

#9

@ccheever ok I see, that’s a great idea. Is the idea to actually put the camera component in one of the initial screens, and just hide the component, or is there something else to it? I didn’t realize doing this kind of initialization would carry over across different screens. Thanks!

0 Likes

#10

yeah make sure the component mounts but just don’t make it visible.

1 Like