mrousavy / react-native-vision-camera

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

✨ Make startRecording() async #1319

Open elirichey opened 2 years ago

elirichey commented 2 years ago

What feature or enhancement are you suggesting?

Hey Marc, this package is amazing and I appreciate all the time and effort you've put into it!

I noticed this in your ToDo file:

Any thoughts on when this might be completed? I'm trying to get an accurate timestamp from when video recording actually starts. Without it being async, the timestamps are off by about 1.3-1.6 seconds in iOS. Android seems to be off by 0.3-0.4 seconds.

I tested iOS on an iPhone 6 and Android on a Galaxy S10 5G

Thanks again,

Eli

What Platforms whould this feature/enhancement affect?

iOS, Android

Alternatives/Workarounds

I'm currently testing on a couple of devices to see if I can find a standard offset. Considering I'm still fact-finding I don't have any exact answers. Though, I imagine this approach will be fruitless. Hard-coding offsets doesn't seam like a viable solution, but I'm going to try it anyway.

Additional information

mrousavy commented 1 year ago

I think such an API makes more sense:

const recorder = await camera.current.prepareRecorder()

await recorder.start()
await recorder.pause()
console.log(recorder.duration)
await recorder.resume()
await recorder.stop()

..exposed as a HostObject using JSI. That way you can also prepare the recorder beforehand to warm it up.

mrousavy commented 11 months ago

Started working on something here: https://github.com/mrousavy/react-native-vision-camera/pull/2194

as of now this doesn't really work, but we'll see what we can do