You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
no ensureDecodableVideoFormat import。
android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt missing
`// MIME type reported by MediaExtractor for Dolby Vision tracks (e.g. iPhone .MOV files)
private const val MIMETYPE_VIDEO_DOLBY_VISION = "video/dolby-vision"
/**
Check whether the device exposes a decoder for the given MIME type.
*/
private fun hasDecoderForMime(mime: String): Boolean {
val codecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
for (codec in codecList.codecInfos) {
if (codec.isEncoder) continue
for (type in codec.supportedTypes) {
if (type.equals(mime, ignoreCase = true)) return true
}
}
return false
}
/**
Resolve the backward-compatible base-layer MIME type for a Dolby Vision track.
Dolby Vision profiles 8.x (DvheSt) and 4 (DvheDtr) carry an HEVC base layer, and
profile 9 (DvavSe) carries an AVC base layer; these can be decoded by the standard
HEVC/AVC decoders. Profiles 5 (DvheStn) and 7 (DvheDtb) have no usable single base
layer, so they return null. When the profile is unknown we assume HEVC, which covers
the common consumer case (e.g. iPhone records Dolby Vision profile 8).
*/
private fun dolbyVisionBaseLayerMime(inputFormat: MediaFormat): String? {
if (!inputFormat.containsKey(MediaFormat.KEY_PROFILE)) {
return MediaFormat.MIMETYPE_VIDEO_HEVC
}
return when (inputFormat.getInteger(MediaFormat.KEY_PROFILE)) {
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvavSe -> MediaFormat.MIMETYPE_VIDEO_AVC
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheSt,
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheDtr -> MediaFormat.MIMETYPE_VIDEO_HEVC
else -> null
}
}
/**
Ensure the input video format can be decoded on this device.
Some containers (notably iPhone .MOV files) expose the video track as
video/dolby-vision. Many Android devices have no Dolby Vision decoder, so
MediaCodec.createDecoderByType("video/dolby-vision") fails with NAME_NOT_FOUND.
When the dedicated decoder is missing but the stream carries a backward-compatible
base layer, this rewrites the format MIME to the base-layer codec so the standard
HEVC/AVC decoder can decode it. If no compatible decoder exists, it throws a clear
if (mime.equals(MIMETYPE_VIDEO_DOLBY_VISION, ignoreCase = true)) {
val fallbackMime = dolbyVisionBaseLayerMime(inputFormat)
if (fallbackMime != null && hasDecoderForMime(fallbackMime)) {
Log.w(
"Compressor",
"No Dolby Vision decoder on this device; decoding the $fallbackMime base layer instead."
)
inputFormat.setString(MediaFormat.KEY_MIME, fallbackMime)
return
}
throw IllegalStateException(
"This video uses Dolby Vision, which is not supported by this device's decoders " +
"and has no backward-compatible base layer to fall back to."
)
}
throw IllegalStateException("No decoder available for video format: $mime")
Activity
zhuminjunivan commentedon Jun 29, 2026
no
ensureDecodableVideoFormatimport。android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt missing
`// MIME type reported by MediaExtractor for Dolby Vision tracks (e.g. iPhone .MOV files)
private const val MIMETYPE_VIDEO_DOLBY_VISION = "video/dolby-vision"
/**
*/
private fun hasDecoderForMime(mime: String): Boolean {
val codecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
for (codec in codecList.codecInfos) {
if (codec.isEncoder) continue
for (type in codec.supportedTypes) {
if (type.equals(mime, ignoreCase = true)) return true
}
}
return false
}
/**
*/
private fun dolbyVisionBaseLayerMime(inputFormat: MediaFormat): String? {
if (!inputFormat.containsKey(MediaFormat.KEY_PROFILE)) {
return MediaFormat.MIMETYPE_VIDEO_HEVC
}
return when (inputFormat.getInteger(MediaFormat.KEY_PROFILE)) {
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvavSe -> MediaFormat.MIMETYPE_VIDEO_AVC
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheSt,
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheDtr -> MediaFormat.MIMETYPE_VIDEO_HEVC
else -> null
}
}
/**
.MOVfiles) expose the video track asvideo/dolby-vision. Many Android devices have no Dolby Vision decoder, soMediaCodec.createDecoderByType("video/dolby-vision")fails with NAME_NOT_FOUND..MOVvideo compression fails withFailed to initialize video/dolby-vision#398).*/
fun ensureDecodableVideoFormat(inputFormat: MediaFormat) {
val mime = inputFormat.getString(MediaFormat.KEY_MIME) ?: return
if (hasDecoderForMime(mime)) return
}
}`
XChikuX commentedon Jun 29, 2026
@numandev1 Please fix and issue an update to v1
XChikuX commentedon Jun 29, 2026
Last working build for v1 for those who are interested is
1.19.0XChikuX commentedon Jul 14, 2026
@numandev1
I have pushed #413. Can we please merge it onto the
1.19.2branch.So you can upload a new version in the
v1series.Thanks!
XChikuX commentedon Jul 22, 2026
1.19.4Builds with no issue.Safe to close.