mrousavy / react-native-vision-camera

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

✨ Exposing available video codes on device #2633

Closed ISnowFoxI closed 5 months ago

ISnowFoxI commented 7 months ago

What feature or enhancement are you suggesting?

Having a function/hook to get the available codes for a particular device would be great. We had issues with old devices where they wouldn't support the h265 codec and the app would crash upon recording start (example: iPad mini 4 and iPad Air 2).

What Platforms whould this feature/enhancement affect?

iOS, Android

Alternatives/Workarounds

Currently, I was not able to find any workarounds.

Additional information

mrousavy commented 7 months ago

Good feature request.

drLeonymous commented 7 months ago

A dirty workaround, just for debugging time, can be:

In CameraView add:

private val codecs = MediaCodecList(MediaCodecList.ALL_CODECS).codecInfos.filter {
    it.isEncoder && it.supportedTypes[0].startsWith("video")
  }
  private val availableVideoCodecs: List<String> = codecs.map { it.name }

Then in init add a log: Log.i(TAG, "Available Video Codecs: $availableVideoCodecs")

Open LogCat and, filter for TAG name, here CameraView and ... check Available Video Codecs

Available Video Codecs: [c2.android.avc.encoder, OMX.google.h264.encoder, c2.android.h263.encoder, OMX.google.h263.encoder, c2.android.hevc.encoder, c2.android.mpeg4.encoder, OMX.google.mpeg4.encoder, c2.android.vp8.encoder, OMX.google.vp8.encoder, c2.android.vp9.encoder, OMX.google.vp9.encoder]

image

;)

mrousavy commented 7 months ago

Nice find @drLeonymous - I definitely want to expose that API to JS!

eleretic commented 6 months ago

I would suggest falling back to H264 when H265 is unavailable, that would be much safer

mrousavy commented 5 months ago

Instead of exposing it, you can just pass h265 and it will automatically fall back to h264 if h265 is not supported. Added in VisionCamera 4.0.0