react-native-compressor 1.19.0 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -788,32 +788,21 @@ object Compressor {
788
788
  inputFormat: MediaFormat,
789
789
  outputSurface: OutputSurface,
790
790
  ): MediaCodec {
791
- val originalMime = inputFormat.getString(MediaFormat.KEY_MIME)!!
792
-
793
- // Dolby Vision (video/dolby-vision) has no standalone decoder on most Android
794
- // devices and throws NAME_NOT_FOUND. Profiles 8.1/8.4 carry an HEVC base layer
795
- // that the standard HEVC decoder can render, so we remap them to HEVC. Profile 5
796
- // has no compatible base layer; it is rejected by isUnsupportedDolbyVision() in
797
- // start() before any codec/surface is created, so it never reaches here.
798
- val resolvedMime = if (originalMime.equals("video/dolby-vision", ignoreCase = true)) {
799
- inputFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_HEVC)
800
- MediaFormat.MIMETYPE_VIDEO_HEVC
801
- } else {
802
- originalMime
791
+ // Some inputs (e.g. iPhone .MOV files) report a "video/dolby-vision" MIME
792
+ // type that many devices cannot decode. Remap to a decodable base-layer
793
+ // codec, or fail with a clear error, before creating the decoder (#398).
794
+ ensureDecodableVideoFormat(inputFormat)
795
+
796
+ // Clear Dolby Vision specific profile and level to prevent configuration failures
797
+ // when the MIME type has been remapped to AVC/HEVC.
798
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
799
+ inputFormat.removeKey(MediaFormat.KEY_PROFILE)
800
+ inputFormat.removeKey(MediaFormat.KEY_LEVEL)
803
801
  }
804
802
 
805
- val decoder = MediaCodec.createDecoderByType(resolvedMime)
806
-
807
- try {
808
- decoder.configure(inputFormat, outputSurface.getSurface(), null, 0)
809
- } catch (e: Exception) {
810
- // A codec that throws from configure() is unusable; release it so a
811
- // configure failure here doesn't leak the decoder handle.
812
- runCatching { decoder.release() }
813
- throw e
814
- }
803
+ val decoder = MediaCodec.createDecoderByType(inputFormat.getString(MediaFormat.KEY_MIME)!!)
815
804
 
816
- Log.i("Compressor", "decoder selected: ${decoder.name} mime=$resolvedMime")
805
+ decoder.configure(inputFormat, outputSurface.getSurface(), null, 0)
817
806
 
818
807
  return decoder
819
808
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "description": "Compress Image, Video, and Audio same like Whatsapp & Auto/Manual Compression | Background Upload | Download File | Create Video Thumbnail",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",